For example, in algebra we may write:
0 < x < 20
to show that x is between 0 and 20, inclusive. In C++ we would write it:
0 <= x && x <= 20
or
x >= 0 && x <= 20
Truth table for logical expressions:
| x | y | x && y | x || y | !x |
|---|---|---|---|---|
| TRUE | TRUE | TRUE | TRUE | FALSE |
| TRUE | FALSE | FALSE | TRUE | FALSE |
| FALSE | TRUE | FALSE | TRUE | TRUE |
| FALSE | FALSE | FALSE | FALSE | TRUE |