int i=0;
while(i<=100)
{
printf("hello world....\n");
i++;
}
For the above program, how can I find the total time of execution of while
loop.
int i=0;
while(i<=100)
{
printf("hello world....\n");
i++;
}
For the above program, how can I find the total time of execution of while
loop.
In header file time.h have that function. you can use that. You can see there is a clock_t variable called start which calls a clock() function. try this:
clock_t start = clock();
for ( i = 0; i < 100; i++ )
rand();
printf ( "%f\n", ( (double)clock() - start ) / CLOCKS_PER_SEC );
it will give you execution time. for this check your conditioj in while loop. it should "< 100" i think. check this code it will work for you.