if statement error

whichever number I type it is showing row 1. can anyone help please
here's the code
#include <iostream>

using namespace std;

int main()
{cout << "choose any no.";

int arrayr[2][3]{ {234,4,6},{235,56,12}};
for (int row = 0 ; row <2;row++){
for (int col = 0 ; col < 3;col++){
cout << arrayr[row][col]<< " ";

}
cout << endl;

}int x;
cin >> x;
if (x=234||56||12)
cout << "row 1";
else if (x = 235||56||12)
cout << "row 2";
else cout << "invalid entry";
}
x=234||56||12 It is wrong on so many levels:
x=234 ← assigment. It sets x to 234 and returns new value (234). As any non-zero value is true in bool context it will be true.
56 and 12: As any non-zero value is true in bool context it will be true.

So your condition is actually true||true||true which is obviously true.

You probably want to write if( x == 234 || x == 56 || x == 12) here. Same for second condition.
Topic archived. No new replies allowed.