Hi members,
I wrote a code that calculates the execution time of the for loop.
Code:
#include <stdio.h>
#include <time.h>
int main( )
{
clock_t start, stop;
int x;
double duration;
start = clock(); // get number of ticks before loop
for( x = 0; x < 10; x++ ){
printf("Hello");
}
stop = clock(); // get number of ticks after loop
// calculate time taken for loop
duration = ( double ) ( stop - start ) / CLOCKS_PER_SEC;
printf( "Time taken is: %f\n", duration );
return 0;
}
What is the unit of the value that is derived in the variable 'duration'? Is it in seconds or milliseconds?