Advertisement
AntonioVillanueva

clock c

Oct 30th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. //compiler avec ... gcc -o heures heures.c
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  #include <unistd.h>
  5. int main (){
  6.     int h,m,s;
  7.  
  8.     printf ("saisir les 3 variables ");
  9.     scanf (" %d %d %d",&h,&m,&s);
  10.     printf ("setup heure= %d ,min=%d ,sec=%d \n",h,m,s);
  11.    
  12.     while (1){  //Boucle test 1 sec
  13.    
  14.         if (s<59){s++;}
  15.         else {s=0;m++;}
  16.    
  17.         if (m>59){m=0;h++;}
  18.    
  19.         if (h>23 ){h=0;}
  20.    
  21.         printf ("%d : %d : %d\n",h,m,s);
  22.         sleep(1);//1 sec. retard
  23.     }
  24.    
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement