-
Notifications
You must be signed in to change notification settings - Fork 16
/
2.c
45 lines (34 loc) · 711 Bytes
/
2.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
#include <stdio.h>
struct time
{
int hour;
int minute;
int second;
};
void incrementTime(struct time *time)
{
time->second++;
if (time->second == 60)
{
time->second = 0;
time->minute++;
if (time->minute == 60)
{
time->minute = 0;
time->hour++;
}
}
}
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);
incrementTime(&time);
printf("The updated time is: %02d:%02d:%02d\n", time.hour, time.minute, time.second);
return 0;
}