EmbLogic's Blog

C program for digital clock

#include

int main()
{
int sec=0,min=0,hour=0,i,j;
while(1)
{

if(sec>59)
{
min++;
sec=0;
}
if(min>59)
{
hour++;
min=0;
}
if(hour>23)
{
hour=0;
min=0;
sec=0;
}
sleep(1);
sec=sec+1;
system(“clear”);
printf(“\t\t%d:%d:%d\n”,hour,min,sec);

}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>