Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- //This is a very simple loop C program
- //Author: Derek ------
- //Date: 11/01/2012
- */
- #include <stdio.h>
- int main()
- {
- int seconds = 0, minutes = 0, miliseconds = 0, hours = 0; //start timer at 00:00:00.0
- for(int x = 0; /*x < infinity*/; x++)
- {
- if(x % 25000000 == 0) //allow time to pass in loop: 25,000,000
- {
- if(miliseconds>=9)
- {
- x = 0; //restart the loop
- seconds++; //add a second
- }
- miliseconds = x/25000000; //set miliseconds number
- if(seconds>59)
- {
- seconds = 0; //reset seconds
- minutes++; //add a minute
- }
- if(minutes>59)
- {
- minutes = 0; //reset minutes
- hours++; //add an hour
- }
- for(int lines = 0; lines<12; lines++) printf("\n"); //put text in middle line
- if(hours<10)
- {
- printf("%37d%d:", 0, hours); //0#:
- }
- else
- {
- printf("%37d:", hours); //##
- }
- if(minutes<10)
- {
- printf("0%d:", minutes); //--:0#:
- }
- else
- {
- printf("%d:", minutes); //--:##:
- }
- if(seconds<10)
- {
- printf("0%d.", seconds); //--:--:0#.
- }
- else
- {
- printf("%d.", seconds); //--:--:##.
- }
- printf("%d", miliseconds); //--:--:--.#
- for(int lines = 0; lines<12; lines++) printf("\n"); //enter down by a whole screen to
- //create illusion that numbers stay in place
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment