program execution time calculate in c

[ad_1]

program execution time calculate in c
#include 

     clock_t start, end;
     double cpu_time_used;

     start = clock();
     ... /* Do the work. */
     end = clock();
     cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
C Program to calculate the total execution time of a program
#include
#include
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
	}
	end = clock();
	//time count stops
	total_time = ((double) (end - start)) / CLK_TCK;
	//calulate total time
	printf("\nTime taken to print 25000 random number is:
	return 0;
}

[ad_2]

Please follow and like us:
Content Protection by DMCA.com