execution time of c program
clock_t begin = clock();
/* here, do your time-consuming job */
clock_t end = clock();
double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
execution time of c program
clock_t begin = clock();
/* here, do your time-consuming job */
clock_t end = clock();
double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
C Program to calculate the total execution time of a program
#include<stdio.h>
#include<time.h>
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[%d]= %d\n", i + 1, rand());
}
end = clock();
//time count stops
total_time = ((double) (end - start)) / CLK_TCK;
//calulate total time
printf("\nTime taken to print 25000 random number is: %f", total_time);
return 0;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us