Chat with us, powered by LiveChat Program that Contains Code that Calculates the Running Time Question - STUDENT SOLUTION USA

Write a program in C++ that contains code that calculates the running time to do the following:

In a loop that runs from 0 to 1,000,000, allocate an array of 100,000 doubles statically (before runtime)

In a second loop that runs from 0 to 1,000,000 allocate an array of 100,000 doubles on the run time stack (a variable in a function)

In a third loop create an array of 100,000 doubles dynamically (at runtime).

To time your loops include time.h in your code. Next create variables

clock_t start = 0, end = 0;

To start the clock use: start = clock();

To end the clock after the loop use end = clock();

Next print the difference to see how long the loop took.

error: Content is protected !!