(4 < 8 ) && (12 <= 40 ) && (50 > 1)
is true
An expression with two && operators works like you expect. But let us look at the situation in detail. When the && operator is used twice in an expression, group the first && and its operands together like this:
(4 < 8 ) && (12 <= 40 ) && (50 > 1) is equivalent to: ( (4 < 8 ) && (12 <= 40 )) && (50 > 1)
Now evaluate that first group.
The result is a true
or false
that is used with the next && operator:
( true ) && (50 > 1)
The effect of this is that for the entire expression to
be true
, every operand must be true
.
One or more false
values cause the entire expression
to be false
.
Short-circuit evaluation is still going on, so
the first false
value stops evaluation and
causes the entire expression to be false
.
What is the value of:
(4 < 8 ) && ( 8 < 0 ) && ( 100 > 45 )