-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathClock.c
More file actions
41 lines (40 loc) · 729 Bytes
/
Clock.c
File metadata and controls
41 lines (40 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//C program to display a Digital Clock
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void delay(unsigned int m_sec)
{
clock_t goal = m_sec + clock();
while (goal > clock());
}
int main()
{
int hr=0,min=0,sec=0;
time_t now;
time(&now);
struct tm *local = localtime(&now);
hr = local->tm_hour;
min = local->tm_min;
sec = local->tm_sec;
int i,j,k;
for(i=hr;i<=23;i++)
{
for(j=min;j<=59;j++)
{
for(k=sec;k<=59;k++)
{
printf("\n The current time is: %d : %d : %d",i,j,k);
delay(1000);
system("cls");
sec=0;
}
printf("\n%d : %d : %d",i,j,k);
system("cls");
min=0;
}
printf("\nTime is: %d : %d : %d",i,j,k);
system("cls");
hr=0;
}
return 0;
}