Advertisement
Sierra_ONE

Seconds Clock

Oct 8th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | Source Code | 0 0
  1. /*
  2. 1. Seconds Clock
  3. Hey, do you think you could help me? I think my clock is broken. It used to show the time in hours, minutes, and seconds, but now it only shows it in seconds. I don't have enough money to buy a new one so I figured you could help me out with this. Help me convert the time in my clock to hours, minutes, and seconds. Thanks! I owe you one.
  4.  
  5. Inputs
  6.  
  7. 1. Time in seconds
  8. */
  9.  
  10.  
  11. #include <stdio.h>
  12.  
  13. int main (void){
  14.     int time, sec, min, hr;
  15.  
  16.     printf("Enter the time (seconds): ");
  17.     scanf("%d", &time);
  18.  
  19.     hr = time / 3600;
  20.     time = time % 3600;
  21.     min = time / 60;
  22.     sec = time % 60;
  23.  
  24.     printf("%d hr %d min %d sec", hr, min, sec);
  25.  
  26.  
  27.  
  28.  
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement