Ask Question

Write three functions in C or C : one that declares a large array statically, one that declares the same large array on the stack, and one that creates the same large array on the heap. Call each of the subprograms a large number of times (at least 100,000) and output the time required by each. Explain the results.

+1
Answers (1)
  1. 9 October, 04:26
    0
    The function is shown tin the explanation below:

    Explanation:

    The C or C+ + function is given by the following function presentation:

    # include

    # include

    # include

    void static_allocation ()

    static int array[400000]; static array memory is alloted in program's data segment

    void allocation_in stack_memory ()

    int array1[400000]; non static array memory allocation is done on stack, internally it calls alloca () to allocate which allocates from stack.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write three functions in C or C : one that declares a large array statically, one that declares the same large array on the stack, and one ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers