Boolean expressions with relational operators

A boolean expression is one that has a value that is either true or false. Use a boolean variable to hold the value of a boolean expression.

A relational operator is one that compares two values and produces a boolean result. (In contrast, an arithmetic operator combines one or more values to produce a new arithmetic value.)

  Relational operators  
Symbol
Meaning
Example
==
equal to if ( a == 5 )
>
greater than if ( salary > 30000 )
<
less than if ( 0 < salary )
!=
not equal to if ( a != b )
>=
greater than or equal to if ( salary >= 10000 )
<=
less than or equal to if ( 20000 <= salary )