fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3. #define N 100000000
  4.  
  5. int main() {
  6. double sum = 0.0;
  7. clock_t start = clock();
  8.  
  9. for (long i = 0; i < N; i++) {
  10. sum += i * 0.0000001;
  11. }
  12.  
  13. clock_t end = clock();
  14. double elapsed = (double)(end - start) / CLOCKS_PER_SEC;
  15.  
  16. printf("Sum = %f\n", sum);
  17. printf("Time = %f seconds\n", elapsed);
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.09s 5320KB
stdin
Standard input is empty
stdout
Sum = 499999995.000000
Time = 0.086008 seconds