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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include<stdio.h>
#include<time.h>

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

start = clock();//time count starts

srand(time(NULL));
for (i = 0; i < 25000; i++)
{
printf("random_number[%d]= %dn", 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 Follow @c_program

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!

(c) www.c-program-example.com