Advertisement
mahatma_xande

ex02lista06

Aug 28th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. /*
  2. It is a Clock! Set the initial parameters: hours (h), minutes (m) and seconds (s).
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <windows.h>
  7. #include <conio.h>
  8.  
  9. int main(){
  10.  
  11.     int h, m, s;
  12.  
  13.     printf("Enter h, m, s: ");
  14.     scanf("%d %d %d", &h, &m, &s);
  15.  
  16.     while(!kbhit()){
  17.         system("cls");
  18.         printf("elapsed time (h:m:s): %2d : %2d : %2d\n", h, m, s++);
  19.         Sleep(1000);
  20.  
  21.         if(s == 60){
  22.             s = 0;
  23.             m++;
  24.         }
  25.  
  26.         if(m == 60){
  27.             m = 0;
  28.             h++;
  29.         }
  30.     }
  31.  
  32.     printf("\nEnd!\n");
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement