-
Notifications
You must be signed in to change notification settings - Fork 16
/
4.c
53 lines (42 loc) · 819 Bytes
/
4.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
#include <stdio.h>
struct date
{
int day;
int month;
int year;
};
struct date incrementDate(struct date d)
{
int daysInMonth = getDaysInMonth(d.month, d.year);
if (d.day < daysInMonth)
{
d.day++;
}
else
{
d.day = 1;
if (d.month < 12)
{
d.month++;
}
else
{
d.month = 1;
d.year++;
}
}
return d;
}
int main()
{
struct date date;
printf("Enter the day: ");
scanf("%d", &date.day);
printf("Enter the month: ");
scanf("%d", &date.month);
printf("Enter the year: ");
scanf("%d", &date.year);
struct date newDate = incrementDate(date);
printf("The updated date is: %d-%d-%d\n", newDate.day, newDate.month, newDate.year);
return 0;
}