
Do not confuse the equality
operator == (double equal
signs) with the assignment
operator = (one equal
sign).
COMMON ERROR
TRAP
210 CHAPTER 5 Flow of Control,Part 1: Selection
TABLE 5.2 Relational Operators
Relational Operator Type Meaning
< binary is less than
<= binary is less than or equal to
> binary is greater than
>= binary is greater than or equal to
Assuming the user’s input is stored in the char variable playAgain, then if
the user typed ‘y’, the expression evaluates to true; with any other input
value, the expression evaluates to false.
A common error is to use the assignment operator instead of the equality
operator. For example:
playAgain = 'y'
assigns ...