There are three logical operators in C++: AND, OR and NOT, which are
denoted by the symbols
. The semantics (meaning) of these operators is similar to their meaning
in English. For example
dX > 0 && dX < 10
is true only if dX is greater than zero AND less than 10.
bEvenFlag || iN%3 == 0
is true if either of the conditions is true, that is, if bEvenFlag is
true OR the number is divisible by 3.
Finally, the NOT operator has the effect of negating or inverting a bool
is true if bEvenFlag is false; that is, if the number is odd.
Logical operators often
provide a way to simplify nested conditional statements. For example,
it is easy to write the following code: