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.
i=0 and in while loop it says i>=100
while( i <= 100 ). It's already been answered here: stackoverflow.com/questions/5248915/execution-time-of-c-programwhile(i>=100)intowhile(i <= 100)