In this your phrase
If 1 is equal to 2 or 4, then print true
you need to add a pair of words that to get a correct equivalent C++ phrase
If 1 is equal to 2 or is equal to 4, then print true
Thus it will look the following way
if ( 1 == 2 or 1 == 4 )
{
cout << "True";
}
else
{
cout<<"False";
}
As for the original condition
1 == 2 || 4
then the compiler consideres it the following way (due to the priorities of the operators):
( 1 == 2 ) || 4
According to the C++ Stanbdard
The operators == and != both yield true or false, i.e., a result of
type bool.
So as 1 == 2 is equal to false
then you get
false || 4
where 4 as it is not equal to 0 is converted to boolean true
and as result the entire condition evaluates to true