Don't get confused with Precedence and Order of evaluation.
The order of evaluation of logical OR ||
is left to right.
So if left = true
then left || right
will never execute right
. In your code exactly same happened.
As you know, any non zero value treated as true
in C, hence, ++i
or -2
is true
. So,
m = ++i || ++j && ++k;
m = true || bla bla bla; //right not even checked!
m = true
m = 1
And you get the output as expected.