Program for updating the date by one day

1264
Program for updating the date by one day
#include<stdio.h>
#include<conio.h>
void main()
{
 in d,m,y;
 clrscr();
 printf("Enter date d, m, y\n");
 scanf("%d%d%d",&d, &m, &y);
        /* Increase the day by one */
 d++;
 if(d>31)
    {
     d=1;
     m++;
    }
 if((d>30)&&((m==4)||(m==6)||(m==9)||(m==11)))
    {
     d=1;
     m++;
    }
 if((d>29)&&(m==2))
    {
     d=1;
     m++;
    }
 if((d>28)&&(m==2)&&(y%4!=0))
    {
     d=1;
     m++;
    }
 if(m>12)
    {
     m=1;
     y++;
    }
 printf("\n updated date is %4d%4d%8d",d,m,y);
 getch();
}
  Ouptput 1:
  Enter date d, m, y
  20 2 2002

  the dated date is 20 2 2002
  Output 2:
  Enter date d, m, y
  32 2 2002
  
  the update date is 1 4 2002

As shown in the output 2 of the above program, the program will not check for 
validity of date. The following program checks for validity of the given date.
When it is valid it updated the date otherwise it gives just the message 
"invalid date".   

 

Program for updating the date by one day Program for updating the date by one day in C C Program for updating the date by one day Example of nested if statement