-
Notifications
You must be signed in to change notification settings - Fork 16
/
5.c
46 lines (37 loc) · 753 Bytes
/
5.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 date
{
int day;
int month;
int year;
};
struct date incrementDate(struct date d)
{
int daysInMonth;
daysInMonth = getDaysInMonth(d.month, d.year);
d.day++;
if (d.day > daysInMonth)
{
d.day = 1;
d.month++;
}
if (d.month > 12)
{
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;
}