Digital Timer Simulation in C-Langauge(Turbo C++) using nested for loops, delay() and clrscr() fucntions.

Leave a Comment
#include<stdio.h>      //for standard input/output function
#include<conio.h>     //for console input/output related function
#include<time.h>      //for time related function
void main()
{
int sec,min,hour;
for(hour=0;sec<=24;hour++)
{
for(min=0;min<=60;min++)
{
for(sec=0;sec<=60;sec++)
gotoxy(12,50);
//To print the text at 12th coloum and 50th row of the screen textcolor(4+128);
//To set Red Color and Blink
cprintf("Timer Simulation By Shariq Khan,Press Any Key To Exit");
textcolor(2);
gotoxy(30,16);
cprintf("****************");
//To print *
gotoxy(35,18);
cprintf("H:M:S");
gotoxy(35,20);
cprintf("%d:%d:%d",hour,min,sec);
gotoxy(30,22);
cprintf("****************");
delay(1000);
//To halt the execution for 1000 miliseconds(1 sec)
if(kbhit()) //To check for any key pressed by user
exit(1);//if key is pressed then program is stopped
}
}
getche();
}

0 comments: