what is wrong with the if...?

#include <iostream>
using namespace std;

int main() {
int year;
cout<<"enter a year:";
cin>>year;
if(year%4==0) %% (year&100!=0) || (year %400==0)
cout<<"this is a leap year\n";
else
cout<<"this is not a leap year\n";
return 0;
i also if someone knows how can i put the date mm/dd/year and then check if is a leap year. im little confused . im a bigginer so... anyone
#include <iostream>
#include <cmath>
using namespace std;
int 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;
}
You forgot to put parenthesis in the code and (&&) operator which does logical AND function
code should be as follows:

#include <iostream>
using namespace std;
int main() {
int year;
cout<<"enter a year:";
cin>>year;
if((year%4==0) && (year&100!=0) || (year %400==0)){
cout<<"this is a leap year\n";
}
else{
cout<<"this is not a leap year\n";
}
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
using namespace std;

int main() {
int year;
cout<<"enter a year:";
cin>>year;
if(year%4==0) %% (year&100!=0) || (year %400==0)
cout<<"this is a leap year\n";
else
cout<<"this is not a leap year\n";
return 0;


FAIL !!

tell me exactly what you want this program to do, and for what you need it, so that i can help you.
Are you even paying attention to what you're writing?
You mistyped && and %, you forgot two parenthesis and a closing bracket and you misspelled "Enter".
The (non-existent) problem description tops it off.
Compilers are not as forgiving as some people are, so programming is probably not for you.
Topic archived. No new replies allowed.