Swich-case statement
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int d,m,y,maxday,t,i;
clrscr();
printf("enter a date");
scanf("%d %d %d",&d,&m,&y);
printf("enter your increase day");
scanf("%d",&i);
fflush(stdin);
switch(m)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
maxday=31;
break;
case 4:
case 6:
case 9:
case 11:
maxday=30;
break;
case 2:
if((y%4==0) && (y%100!=0) || y%400==0)
maxday=29;
else
maxday=28;
break;
}
printf("max days are %d\n",maxday);
d=d+i;
if(d>maxday)
{
d=d-maxday;
m++;
if(m>12)
{
m=m-12;
y++;
}
}
printf(" %d %d %d",d,m,y);
getch();
}
Post a Comment