Assume that x
contains 9 and y
contains 7.
The expression evaluates to False. One way to show this is below.
A truth table shows the evaluation of a boolean expression.
The table at right has four rows for the truth values,
one row for each of the four possible choices for the two operands.
(The operands are the relational expressions x<12
and y>10
.)
The last column shows the result of the
&&
operator
with those values.
Operands | Boolean Expression | |
---|---|---|
x < 12 | y > 10 | x < 12 && y > 10 |
F | F | F |
F | T | F |
T | F | F |
T | T | T |
What row of the table is used when x
contains 1 and y
contains 23?