If-statement seemingly going off track

Hello
I've been messing around with this for a bit but I can't seem to find a solution to this problem.
When I run my code and I try to make it run the else if statement it runs the if statement instead. I hope some of you can help me with this little problem.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  <iostream>
using namespace std;
int statement1=1,statement2=1;
main()
{

  if((statement1==1)||statement2==1)&&(statement1==2)||(statement 2==2))
{
  Do something              //Runs this
}

else if((statement1==1)&&(statement2==1))
{
  Do something else
}

return 0
}

Thanks in advance :)
&& has higher precedence than ||, so (a || b && c || d) evaluates to (a || (b && c) || d). Did you mean to parenthesize as ((a || b) && (c || d))?
Yeah I think so. What I'm trying to do is make a menu where I can choose two options including the same option twice. I would imagine that's the way of doing it. Am I wrong?
I fixed the problem by saying

1
2
3
4
if (statement1==1 && statement2==2) || (statement1==2 && statement2==1)
{
   //Do something
}

Instead.
Topic archived. No new replies allowed.