So far we’ve studied only simple conditions, such as counter <= 10
, total > 1000
and number != sentinelValue
. We expressed these conditions in terms of the relational operators >
, <
, >=
and <=
, and the equality operators ==
and !=
. Each decision tested precisely one condition. To test multiple conditions while making a decision, we performed these tests in separate statements or in nested if
or if
...else
statements.
C++ provides logical operators that are used to form more complex conditions by combining simple conditions. The logical operators are &&
(logical AND), ||
(logical OR) and !
(logical NOT, also called logical negation).