-
Notifications
You must be signed in to change notification settings - Fork 16
/
3.c
46 lines (35 loc) · 730 Bytes
/
3.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
#include <stdio.h>
struct time
{
int hour;
int minute;
int second;
};
struct time incrementTime(struct time t)
{
t.second++;
if (t.second == 60)
{
t.second = 0;
t.minute++;
if (t.minute == 60)
{
t.minute = 0;
t.hour++;
}
}
return t;
}
int main()
{
struct time time;
printf("Enter the hour: ");
scanf("%d", &time.hour);
printf("Enter the minute: ");
scanf("%d", &time.minute);
printf("Enter the second: ");
scanf("%d", &time.second);
struct time newTime = incrementTime(time);
printf("The updated time is: %02d:%02d:%02d\n", newTime.hour, newTime.minute, newTime.second);
return 0;
}