Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  timer 3 min
Language: C/C++
Code:
#include <time.h>
#include <stdio.h>
int main()
{
    int msec = 0, trigger = 180000; /* 3minutes */
    //int msec = 0, trigger = 10000;
    int iterations = 0;
    clock_t before = clock();
    do 
    {
      clock_t difference = clock() - before;
      msec = difference * 1000 / CLOCKS_PER_SEC;
      iterations++;
    } while ( msec < trigger );
    printf("Time taken %d seconds %d milliseconds (%d iterations)n", msec/1000, msec%1000, iterations);
}
          
Comments: