+ 2

To print a time taken to execution by function

Using build fuction and corresponding header file

12th Mar 2019, 12:03 PM
Ashish ohri
Ashish ohri - avatar
3 Réponses
+ 4
We can use clock() function provided by <time.h> header file to calculate the CPU time consumed by a task within a C application. It returns clock_t type which stores the number of clock ticks. In order to compute the number of seconds elapsed, we need to divide the number of clock ticks elapsed by CLOCKS_PER_SEC macro (also present in <time.h>)  You can look for examples online. Hope it helps!
13th Mar 2019, 2:51 AM
Animesh Singh
Animesh Singh - avatar
+ 4
This code should not run in sololearn because of missing library files on sololearn's compiler but it will work on turbo c/cpp compiler. https://code.sololearn.com/csQKGJRWpb4w/?ref=app
13th Mar 2019, 2:53 AM
Animesh Singh
Animesh Singh - avatar
+ 2
Thanks
16th Mar 2019, 12:16 PM
Ashish ohri
Ashish ohri - avatar