Create Your Own Digital Clock In C Language
2 years ago
2
In this video we will learn about how to create a digital clock using c language
SOURCE CODE
#include <stdio.h>
#include <windows.h>
int main()
{
int h,m,s;
int d=1000;
// we add a delay of 1000 milliseconds and we will use it in the function sleep
printf("Set time : \n");
scanf("%d%d%d",&h,&m, &s);
if(h>12 || m>60 || s>60)
{
printf("ERROR ! \n");
exit(0);
}
while(1)
// this is an infinite loup and anything inside will repeat itself to infinity
{
s++;
if(s>59)
{
m++;
s=0;
}
if(m>59)
{
h++;
m=0;
}
if(h>12)
{
h=1;
}
printf("\n Clock :");
printf("\n d:d:d",h,m,s);
// this writes our time in this format 00:00:00
Sleep (d);
// the function sleep slows down the while loop and make it more like a real clock
system("cls");
// this clears the screen
}
}
Loading comments...
-
LIVE
Joe Pags
1 hour agoBiden Out!
3,344 watching -
LIVE
DDayCobra
2 hours agoJoe Biden QUITS
1,969 watching -
LIVE
NEWSMAX
8 months agoNEWSMAX2 LIVE | Real News for Real People
5,492 watching -
LIVE
RealAmericasVoice
20 days agoREAL AMERICA'S VOICE 24/7
6,824 watching -
19:24
Cody and Kellie
7 hours agoSummiting the Third Tallest Peak in Oregon
26.7K16 -
4:23:07
LumpyPotatoX2
7 hours agoFortnite on Sunday - #RumbleTakeover
36K3 -
13:20
barstoolsports
1 day agoWe Broke The MLB Home Run Record In 6 Hours
47.3K3 -
49:50
The Osbournes
5 days ago $15.94 earnedAre The Osbournes Leaving Hollywood?
129K115 -
10:48
Dr. Eric Berg
8 hours agoHow Grocery Stores TRICK US!!
63K45 -
22:41
GEN
9 days ago $0.04 earnedAsking Americans Who They Are Voting For (Post-Debate)
65.4K93