Ask Question
27 June, 22:25

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.

+3
Answers (1)
  1. 28 June, 00:30
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers