Oct 13, 2011

C Program to calculate the total execution time of a program.

C Program to calculate the total execution time of a program. Here we used the "time.h" preprocessor. In this program we used the clock_t variables start and end , They starts the time counter and ends the counter. Execution time of a program is useful to calculate the efficiency of the program.
Read more about C Programming Language .

* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*                      Happy Coding


int main() 
 int i;
 double total_time;
 clock_t start, end;

 start = clock();//time count starts 

 for (i = 0; i < 25000; i++) 
  printf("random_number[%d]= %d\n", i + 1, rand());
 end = clock();//time count stops 
 total_time = ((double) (end - start)) / CLK_TCK;//calulate total time
 printf("\nTime taken to print 25000 random number is: %f", total_time);
 return 0;
Read more Similar C Programs
Learn C Programming

Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!