Advertisement
LOVEGUN

Digital Clock (Personal Project)

Oct 13th, 2021 (edited)
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <windows.h>
  4.  
  5. int main()
  6. {
  7.     int delay,s,m,h;
  8.     delay=1;
  9.     printf ("Set your time (hh/mm/ss): ");
  10.     scanf ("%d%d%d",&h,&m,&s);
  11.     if (s>60 || m>60 || h>24)
  12.     {
  13.         system ("color 44");
  14.         printf ("ERROR ! Wrong time");
  15.         exit (0);
  16.     }
  17.     while (1)
  18.     {
  19.         s++;
  20.         if (s>59)
  21.         {
  22.             s=0;
  23.             m++;
  24.         }
  25.         if (m>59)
  26.         {
  27.             m=0;
  28.             h++;
  29.         }
  30.         if (h>23)
  31.         {
  32.             h=0;
  33.         }
  34.  
  35.         printf ("\nYour time : %02d : %02d : %02d",h,m,s);
  36.         sleep(delay);
  37.         system ("cls");
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement