warfighter67

Untitled

Nov 12th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. //This is a very simple loop C program
  3. //Author:   Derek ------
  4. //Date:     11/01/2012
  5. */
  6. #include <stdio.h>
  7. int main()
  8. {
  9.     int seconds = 0, minutes = 0, miliseconds = 0, hours = 0; //start timer at 00:00:00.0
  10.     for(int x = 0; /*x < infinity*/; x++)
  11.     {
  12.         if(x % 24500000 == 0) //allow time to pass in loop: 24,500,000
  13.         {
  14.             if(miliseconds>=9)
  15.             {
  16.                 x = 0; //restart the loop
  17.                 seconds++; //add a second
  18.             }
  19.             miliseconds = x/24500000; //set miliseconds number
  20.  
  21.             if(seconds>59)
  22.             {
  23.                 seconds = 0; //reset seconds
  24.                 minutes++; //add a minute
  25.             }
  26.  
  27.             if(minutes>59)
  28.             {
  29.                 minutes = 0; //reset minutes
  30.                 hours++; //add an hour
  31.             }
  32.  
  33.             for(int lines = 0; lines<12; lines++) printf("\n"); //put text in middle line
  34.  
  35.             if(hours<10)
  36.             {
  37.                 printf("%37d%d:", 0, hours); //0#:
  38.             }
  39.             else
  40.             {
  41.                 printf("%37d:", hours); //##
  42.             }
  43.             if(minutes<10)
  44.             {
  45.                 printf("0%d:", minutes); //--:0#:
  46.             }
  47.             else
  48.             {
  49.                 printf("%d:", minutes); //--:##:
  50.             }
  51.             if(seconds<10)
  52.             {
  53.                 printf("0%d.", seconds); //--:--:0#.
  54.             }
  55.             else
  56.             {
  57.                 printf("%d.", seconds); //--:--:##.
  58.             }
  59.             printf("%d", miliseconds); //--:--:--.#
  60.  
  61.             for(int lines = 0; lines<12; lines++) printf("\n"); //enter down by a whole screen to
  62.                                                                 //create illusion that numbers stay in place
  63.         }
  64.     }
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment