SOMETHING MORE MISSING IN THIS PROGRAM

#include <iostream>

using namespace std;
void main(){
int day,month,year;
cout<<"enter day";
cin>>day;
cout<<"enter month";
cin>>month;
cout<<"enter year";
cin>>year;

if (day>31 && day<1)
{
cout<<day<<"wrong date"<<endl;

}
if (month <1 && month>12)
{
cout<<month<<"wrong month"<<endl;
}
if (year %4 == 0)
{
cout<<"leap year<"<<endl;

}
if (year%4 >=1)
{
cout<<"not a leap year"<<endl;

}
if (year%100==0)
{
cout<<"century year"<<endl;

}
if (year%400 == 0)
{
cout<<"century leap year"<<endl;

}
if (month == 2 && year%4 == 0)
{
cout<<"february has 28 in every year except the leap year"<<endl;

}
return 0;
}



// can anyone help?????????????????????????
Last edited on
ok...
Last edited on
NOOOOOOOOOOOOOOOOO!
The code above is wrong.
Lines 6 to 9 won't do anything, and conio is nonstandard.
Here is better code:
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
#include <iostream>
#include <cstdio>
int main()
{
	using namespace std;
        int d,m,y;
	const int month_days[12]={31,29,31,30,31,30,31,31,30,31,30,31};//days in each month
        do{
        cout<<"day : "; cin>>d;
        cout<<"month : "; cin>>m;
        cout<<"year : "; cin>>y;
	if(m<1||m>12){
		cout<<"Bad month"<<endl;
		continue;
	}
	if(d<1||d>month_days[m-1]){
		cout<<"Bad day"<<endl;
		continue;
	}
        if (y%4==0 && (y%100!=0 || y%400==0)){
        	cout<<"leap year"<<endl;
        	if(m==2&&d==29)cout<<"leap day: february 29th"<<endl;
        }else if(m==2&&d==29)cout<<"Bad day"<<endl;
        cout<<endl;
       	getchar();
}

Last edited on
something is wrong mate
whoops, my bad. add }while(0); after line 23, and change line 23 to:
}else if(m==2&&d==29){cout<<"Bad day"<<endl; continue;}
Last edited on
Topic archived. No new replies allowed.