0

I need to run a segment of code like shown:

 sum = 0;
 for(i = 0; i < n; i++)
     for(j = 0; j < i; j++)
         sum++;

and find the running times of several values of N and the growth rate associated with those values.

Right now I am using Dev C++ (could use any IDE), but I can't figure out a way to actually display the run times.

1 Answer 1

1

You can:

  1. Time in the application. For instance, use the time() API: http://linux.die.net/man/2/time
  2. Time by wrapping your application in another application, that can time runtimes. On *nix systems, there is a handy utility named time.
  3. Use a stopwatch.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.