Ask Question
7 May, 04:34

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.

+4
Answers (1)
  1. 7 May, 04:55
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers