How to calculate the time required to execute a particular program
The following program shows how to calculate the time taken to execute a program. The program is implemented using c. Here <time.h> header file is included.
Output :
Code :
#include<stdio.h>
#include<time.h>
int main()
{
int i;
clock_t begin,end;
begin=clock();
for(i=0;i<5;i++)
{
printf("Hello world\n");
}
end=clock();
printf("Time taken : %lf\n",(double)(end-begin)/CLOCKS_PER_SEC);
return 0;
}

Comments
Post a Comment