Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. /*
  6. write a function that will determine how many hours, minutes,
  7. and seconds you can get from some number of seconds.
  8. */
  9.  
  10. void timeSegments(int, int*, int*, int*);
  11.  
  12. main(){
  13. int seconds, hours, minutes, secondsIn, secondsOut;
  14.  
  15. secondsIn = 2345;
  16.  
  17. timeSegments(secondsIn, &hours, &minutes, &secondsOut);
  18.  
  19. printf("%d %d %d", hours, minutes, secondsOut);
  20.  
  21.  
  22. }
  23.  
  24.  
  25. void timeSegments(int secondsIn, int *pHours, int *pMinutes, int *secondsOut){
  26.  
  27. *pHours = secondsIn / 3600;
  28. secondsIn %= 3600;
  29. *pMinutes = secondsIn / 60;
  30. secondsIn %= 60;
  31. *secondsOut = secondsIn;
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement