Easy Tutorial
❮ C Function Fgets C Standard Library ❯

C Exercise Example 92

C Language Classic 100 Examples

Title: Time Function Example 2

Program Analysis: None.

Program Source Code:

//  Created by www.tutorialpro.org on 15/11/9.
//  Copyright © 2015 tutorialpro.org. All rights reserved.
//

#include <stdio.h>
#include <time.h>

int main()
{
    time_t start, end;
    int i;
    start = time(NULL);
    for (i = 0; i < 300000; i++)
    {
        printf("\n");  // Returns the time interval between two time_t variables
    }
    end = time(NULL);

    // Output the execution time
    printf("Time interval is %6.3f\n", difftime(end, start));
}

The output result of the above example is:

Time interval is  1.000

C Language Classic 100 Examples

❮ C Function Fgets C Standard Library ❯