Write a program in C++ that contains code addressing the following: (New code and with detailed steps!) a. Create an integer array of 100,000 items (static binding – before compiling) b. Create the same large array on the run time stack (in a function) c. Create the same large array from the heap (dynamic memory – dynamic binding). Call each of the subprograms 1,000,000 times and output the time required by each to finish all 1,000,000 calls. Which was the faste

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question

Write a program in C++ that contains code addressing the following: (New code and with detailed steps!)

a. Create an integer array of 100,000 items (static binding – before

compiling)

b. Create the same large array on the run time stack (in a function)

c. Create the same large array from the heap (dynamic memory –

dynamic binding).

Call each of the subprograms 1,000,000 times and output the time required by

each to finish all 1,000,000 calls. Which was the fastest?

 

 

Here is code for calling time.

#include <time.h>

//in main()

clock_t start = 0, end = 0; //variables

start = clock(); //calls time function stores result in start

end = clock(); // calls time function stores result in end

//display the time by subtracting the start from the end

//displays in clock ticks.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

This doesn't utilize the calling code provided?

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning