C program to create a Simple Clock

hey guys. I hope you're liking my series of Programming Articles.

Here I'm adding one more in the queue. This is a simple program which will show you the current time and the clock will keep ticking.

It actually picks the time from the system clock and then display it on the console. While writing this code I also got the IDEA of writing a Time Bomb Virus :P which I'll share soon.

Here is the code of the your home made clock.

#include<stdio.h>
#include<conio.h>
#include<dos.h>
int main()
{
struct time t;
clrscr();
while(1)
{
printf("\n\t\t\t\t============\n\t\t\t\t=\t   =\n\t\t\t\t= MY CLOCK =");
printf("\n\t\t\t\t=\t   =\n\t\t\t\t============");
gettime(&t);
printf("\n\n\n\n\t\t\t\t  ");
printf("%d:%d:%d",t.ti_hour,t.ti_min,t.ti_sec);
sleep(1);
clrscr();
}
return 0;
}



If you are having troubles in compiling the code then check How to Compile a C code

Output Preview:




Stay tuned for more cool articles.
Previous
Next Post »

2 comments

Click here for comments