Guest User

Untitled

a guest
Jun 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. int main()
  5. {
  6.  
  7. long long total1 = 0, total2 = 0, i = 0;
  8. double simulation_time = 0;
  9.  
  10. clock_t Start = clock();
  11.  
  12. do
  13. {
  14. total1 += i + i;
  15. total2 += i * i * i * i;
  16.  
  17. i++;
  18.  
  19. } while (i < 1000000000);
  20.  
  21. clock_t End = clock();
  22.  
  23. printf("Total 1 = %u n", total1);
  24. printf("Total 2 = %u n", total2);
  25.  
  26. simulation_time = (double)(End - Start) / CLOCKS_PER_SEC;
  27. printf("Runtime of Whole Simulation using clock_t: %fn", simulation_time);
  28.  
  29.  
  30. return 0;
  31. }
Add Comment
Please, Sign In to add comment