#include<iostream.h>
#include<conio.h>
void main()
{
int dd,mm,yy,valid=1;
clrscr();
cout<<"Enter the date,month & year of the date"<<endl;
cin>>dd>>mm>>yy;
if(dd<=0||dd>31||mm<=0||yy<=0)
valid=0;
if((mm==4||mm==6||mm==9||mm==11)&&(dd>30))
valid=0;
if(mm==2&&yy%4==0&&dd>29)
valid=0;
if(mm==2&&yy%4!=0&&dd>28)
valid=0;
if(valid==1)
cout<<"Given date is valid";
else
cout<<"Given date is not valid";
getch();
}
#include<conio.h>
void main()
{
int dd,mm,yy,valid=1;
clrscr();
cout<<"Enter the date,month & year of the date"<<endl;
cin>>dd>>mm>>yy;
if(dd<=0||dd>31||mm<=0||yy<=0)
valid=0;
if((mm==4||mm==6||mm==9||mm==11)&&(dd>30))
valid=0;
if(mm==2&&yy%4==0&&dd>29)
valid=0;
if(mm==2&&yy%4!=0&&dd>28)
valid=0;
if(valid==1)
cout<<"Given date is valid";
else
cout<<"Given date is not valid";
getch();
}
No comments:
Post a Comment