The evaluation of &&
and ||
expressions is complicated by the
fact that certain subexpressions may not be evaluated at all.
In &&
expressions, the left-side operand is evaluated
first: If the value of the left-side operand is 0
, the
right-side operand is ignored completely, and the value of the
&&
expression is 0
.
If both operands evaluate to some integer other than 0
, the
value of the &&
expression is 1
.
In ||
expressions, the left-side operand also is evaluated first: If
the left-side operand evaluates to some integer other than 0
,
nothing else is done, and the value of the ||
expression is
1
; if both operands evaluate to 0
, the value of the ||
expression is 0
.