-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.c
74 lines (68 loc) · 972 Bytes
/
timer.c
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
int main()
{
int sec,min,hrs;
int ch;
yes:do{
printf("\n*****SET TIMER*****\n\n");
printf("Hours:");
scanf("%d",&hrs);
printf("Minutes:");
scanf("%d",&min);
printf("Seconds:");
scanf("%d",&sec);
}while(sec>60 || min>60 || hrs>24);
if(hrs==0 && min==0 && sec==0)
{
printf("\n\"You Have not set a Timer\"");
printf("\nDo You Want To Set a Timer(1/0):");
scanf("%d",&ch);
if(ch==1)
{
goto yes;
}
else
{
exit(0);
}
}
printf("\nTIMER STARTED=====>\n");
int h=hrs;
int m=min;
int s=sec;
if(sec!=0)
{
// s=sec;
goto sec_loop;
}
if(sec==0)
{
goto min_loop;
}
while(h>0)
{
h--;
if(m==0)
{
m=60;
}
min_loop:while(m>0)
{
m--;
if(s==0)
{
s=60;
}
sec_loop:while(s>0)
{
printf("%d:%d:%d\n",h,m,s);
sleep(1);
s--;
}
} //end of m while loop
} //end of h while loop
printf("\nTime's Up...\n");
return 0;
}