• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Lily

a guest Sep 18th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include<stdio.h>
2.   int main()
3.  {
4.      int y1,y2,y3,y4,y5,m1,m2,m3,m4,m5,m6,m7,d1,d2,d3,d4,d5;
5.       printf(" Input your birday YYYY-MM-DD\n");
6.       scanf("%d %d %d",&y1,&m1,&d1);
7.       printf(" Input present date YYYY-MM-DD\n");
8.       scanf ("%d %d %d", &y2,&m2,&d2);
10.       y3=y2-y1;
11.
12.
13. if(m1>m2)
14.     {
15.       y4=y3-1;
16.       m3=m2+12;
17.     }
18. else
19.     {
20.       y4=y3;
21.       m3=m2;
22.     }
23.     m4=m3-m1;
24.
25. if(d1>d2)
26.     {
27.       m5=m4-1;
28.     }
29. else
30.     {
31.        m5=m4;
32.     }
33. if (m5>=12)
34. {
35.     m6=m5-12;
36.     y5=y4+1;
37. }
38.
39. else
40. {
41.     m6=m5;
42.     y5=y4;
43. }
44.                  printf("Year is %d\n",y5);
45.
46. if(d1>d2 && y1%4==0 && m1 ==2)
47.     {
48.       d3=d2+29;
49.     }
50. else if(d1>d2 && m1==1 || m1==3 || m1==5 || m1==7 || m1==8 || m1==10 || m1==12)
51. {
52.     d3=d2+31;
53. }
54. else if(d1>d2 && m1==2)
55.     {
56.       d3=d2+28;
57.     }
58. else if(d1>d2)
59. {
60.     d3=d2+31;
61. }
62. else
63. {
64.     d3=d2;
65. }
66.    d4=d3-d1;
67. if (d4>30)
68.     {
69.     m7=m6+1;
70.     d5 =d4-30;
71.     }
72. else
73. {
74.     m7=m6;
75.     d5=d4;
76. }
77.     printf("Month is %d\n",m7);
78.    printf("Day is %d\n",d5);
79. return 0;
80.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top