-
Notifications
You must be signed in to change notification settings - Fork 0
/
Time converter.c
72 lines (52 loc) · 2.28 KB
/
Time converter.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
#include <stdio.h>
int main() {
int time, hour, min, sec, state;
printf("----------------------------------------------------\n");
printf("Enter your time in hours: \n", hour);
scanf("%d",&hour);
printf("Enter your time in minutes: \n", min);
scanf("%d",&min);
printf("Enter your time in seconds: \n", sec);
scanf("%d",&sec);
if (hour <= 12 && min <= 59 && sec <= 59) {
printf("----------------------------------------------------\n");
printf("Enter 1 for 'am' & 2 for 'pm'\n");
printf("Enter your choice: \n", state);
scanf("%d",&state);
printf("---------------------------------------------\n");
if (state == 1) {
if (hour < 12) {
printf("------------Regular time notation------------\n");
printf("\t\t%d : %d : %d am\n\n", hour, min, sec);
printf("------------Standard time notation-----------\n");
printf("\t\t%d : %d : %d\n\n", hour, min, sec);
}
else {
printf("------------Regular time notation------------\n");
printf("\t\t%d : %d : %d am\n\n", hour, min, sec);
printf("------------Standard time notation-----------\n");
printf("\t\t00 : %d : %d\n\n", min, sec);
}
}
else {
if (hour < 12) {
printf("------------Regular time notation------------\n");
printf("\t\t%d : %d : %d pm\n\n", hour, min, sec);
time = hour + 12;
printf("------------Standard time notation-----------\n");
printf("\t\t%d : %d : %d\n\n", time, min, sec);
}
else {
printf("------------Regular time notation------------\n");
printf("\t\t%d : %d : %d pm\n\n", hour, min, sec);
printf("------------Standard time notation-----------\n");
printf("\t\t%d : %d : %d\n\n", hour, min, sec);
}
}
}
else {
printf("----------------------------------------------------\n");
printf("\t~Your input values are inapplicable~\n");
}
return 0;
}