Logical Operators (Chapter 5)

Main Lab 4 Page


Logical Operators expand on the use of comparison operators, by allowing multiple tests to be included in a single conditional statement.

'And' (&&) and 'or' (||) are two of the most basic logical operators. An 'and' statement will return a value of 'true', if and only if the conditional statements on both sides of the operator are true. An 'or' statement will return a value of 'true', if at least one of the conditional statements on either side of the operator are true.

The following is a demonstration of 'and' and 'or' statements.

TEST 1: It's really hot!

TEST 2: It's bearable.