Question: In this program we will compare the time to create and array of integers using stack dynamic allocation and dynamic memory allocation. a. Write
In this program we will compare the time to create and array of integers using stack dynamic allocation and dynamic memory allocation. a. Write a function that creates an array of 100,000 integers and fill it with O's. Call your function 10,000 times from main. Check time before your loop to call the function and after your loop to call the function. b. From main create an array of 100,00 integers from the heap (dynamic memory). Do this 10,000 times. Check time before your loop and after your loop. What was the time difference between a and b? Here is code for calling time. #include clock_t start = 0, end = 0; start clock(); end = clock(); //display the time by subtracting the start from the end
Step by Step Solution
3.51 Rating (151 Votes )
There are 3 Steps involved in it
The program described in the question appears to be one that compares the performance of two different memory allocation ... View full answer
Get step-by-step solutions from verified subject matter experts
