why does this happen? I want it so that it does not display the text using an or statement and not using and or anything else.

if( 1 == (2 || 2 || 2))
    {
      cout << "Should not display";
    }

I dont understand this question at all. Can you please rephrase? The code you supplied doesnt make any sense. 1 will never equal 2 or 2 or 2...;)

why does this happen? I want it so that it does not display the text using an or statement and not using and or anything else.

if( 1 == (2 || 2 || 2))
    {
      cout << "Should not display";
    }

If atleast one of the statement is true it will go to the condition.

if ( (x==a) || (x==y) || (x==z) ) { //statement
    cout << "Should not display"; //condition
}
Comments
Helpful!

I dont understand this question at all. Can you please rephrase? The code you supplied doesnt make any sense. 1 will never equal 2 or 2 or 2...;)

Yes!!! exactly! but when I compile it. it prints out that message. I don't that phrase to show.

If atleast one of the statement is true it will go to the condition.

if ( (x==a) || (x==y) || (x==z) ) { //statement
    cout << "Should not display"; //condition
}

ahhh Thank you :D.

The result of the || operator will be either 0 or 1.

Let's walk through this:

if ( 1 == (2 || 2 || 2) )
if ( 1 == (1 || 2) )
if ( 1 == 1 )
if ( 1 )

So your condition is always true.

But it appears you've already got the correct wording for what you intended.

This question has already been answered. Start a new discussion instead.