Testing and comparing values

Comparison operators

Expression Meaning Evaluates to

(5 == 10)

5 is equal to 10

false

(5 != 10)

5 is not equal to 10

true

(5 < 10)

5 is less than 10

true

(5 > 10)

5 is greater than 10

false

(5 >= 10)

5 is greater than or equal to 10

false

(5 <= 10)

5 is less than or equal to 10

true

Logic operators

Symbol Logical equivalent True only if:

||

or

either left-hand or right-hand side is true

&&

and

both left-hand and right-hand sides are true

!

not

right-hand side is false