-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnextdate.c
More file actions
83 lines (70 loc) · 1.73 KB
/
nextdate.c
File metadata and controls
83 lines (70 loc) · 1.73 KB
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
73
74
75
76
77
78
79
80
81
82
83
#include<stdio.h>
int main()
{
int d,m,y;
printf("enter the date month and year : ");
scanf("%d %d %d",&d,&m,&y);
if (m>=1 && m<=12)
{
if ((y%4==0 && y%100!=0)|| y%400==0 )
{ if ((m==1||m==3||m==5||m==7||m==8||m==10) && d<=31 && d>=1)
{if (d==31)
printf("the next date is %d %d %d",1,m+1,y);
else
printf("the next date is %d %d %d",d+1,m,y);
}
if(m==12 && d<=31 && d>=1)
{if(d==31)
printf("the next date is &d &d &d",1,1,y+1);
else
printf("the next date is %d %d %d",d+1,m,y);
}
if ((m==4||m==6||m==9||m==11)&& d<=30 && d>=1)
{if(d==30)
printf("the next date is &d &d &d",1,m+1,y);
else
printf("the next date is %d %d %d",d+1,m,y);
}
if (m==2 && d<=29 && d>=1 )
{if (d==29)
printf("the next date is %d %d %d",1,m+1,y);
else
printf("the next date is %d %d %d",d+1,m,y);
}
}
else
{
if (m==1||m==3||m==5||m==7||m==8||m==10 && d<=31 && d>=1)
{
if (d==31)
printf("the next date is %d %d %d",1,m+1,y);
else
printf("the next date is %d %d %d",d+1,m,y);
}
if(m==12 && d<=31 && d>=1)
{
if(d==31)
printf("the next date is %d %d %d",1,1,y+1);
else
printf("the next date is %d %d %d",d+1,m,y);
}
if ((m==4||m==6||m==9||m==11) && d<=30 && d>=1);
{
if(d==30)
printf("the next date is %d %d %d",1,m+1,y);
else
printf("the next date is %d %d %d",d+1,m,y);
}
if (m==2 && d<=28 && d>=1 )
{
if (d==28)
printf("the next date is %d %d %d",1,m+1,y);
else
printf("the next date is %d %d %d",d+1,m,y);
}
}
}
else
printf("your input date is invalid");
return 0;
}