Let me try explain what is happening, then you can follow along and find by yourself what you were missing.
Let's start with your original expression
0&&5||6&&7||4&&!6
This expression is written as a short form without any parentheses.
This is similar to standard mathematical expressions where 2*7+3*8
is understood to mean that the *
has precedence over +
, so this is actually a short form for (2*7)+(3*8)
, and 2*7+3*8+4*3
is short form for ((2*7)+(3*8))+(4*3)
.
In the same way, the above C expression implicit operator precedence can be made explicit by rewriting with parentheses:
( (0&&5) || (6&&7) ) || (4&&!6)
The above step appears to be what you are missing, and therefore you are misinterpreting the meaning of the written expression.
We can then consider the three small parentheses separately:
(0 && whatever)
is 0
(short circuit applies)
(6 && 7)
is 1
(both 6 and 7 are non-zero i.e. true, so result is true)
(4 && !6)
is nonzero && zero
is zero
is 0
(which, as it turns out later, we do not actually need to evaluate)
So... the whole expression
( (0&&5) || (6&&7) ) || (4&&!6)
turns out to be
( 0 || 1 ) || does_not_matter
or
1 || does_not_matter (short circuit applies)
which is 1
.