Calculate Execution Time of C Program

By | November 3, 2016

Let us learn how to find Execution Time of a Program in C programming language. This C program makes use of the time.h header file which has the definitions for clock() method.

In order to calculate the time taken by a C program to complete its execution, the library function clock_t clock(void) returns the clock ticks elapsed since the program started its execution.

The clock() can be invoked at the beginning of the C program with start value and a finish value can be invoked at the end of the C program.

The final running time can be calculated by subtracting the start and finish values.

C Program To Calculate Execution Time of a Program using Time.h Header File


C Program To Calculate Execution Time of a Program

If you have any compilation errors or doubts in this C program to find running time of a program in milliseconds, let us know about it in the comment section below.

Recommended Programs
C Program To Find Day of a given Date
C Program To Print A Christmas Tree
C Program To Create Custom Header Files
C Program To Display Ticking Digital Clock
C Program To Display IP Address
C Program To Print Map of India
C Program To Convert Decimal Number into Binary
C Program To Measure Distance Between Two Points
C Program To Calculate Symmetric Matrix
C Program To Print Permutations of a String

3 thoughts on “Calculate Execution Time of C Program

  1. Ravi Gupta

    OMG! This is fantastic. Now, I don’t need to go to an online compiler to measure the running time of my C program. Thanks a lot CodingAlpha.


Let's Discuss