The logical operator OR, ||

This page introduces the logical operator OR.

In Java and some other languages the lpgical operator OR is written ||.

Jess wants to enrol in a course, but there are conditions for enrolment: a person can enrol if they have passed Maths 1 or if they have passed Stats 1. So Jess can enrol if

Jess has passed Maths 1 OR Jess has passed Stats 1

This tells you that:

  • Jess has passed both Maths 1 and Stats 1 means that Jess can enrol.
  • Jess passed Maths 1 but not Stats 1 means that Jess can enrol.
  • Jess did not pass maths 1 but did pass Stats 1 means that Jess can enrol.
  • Jess failed both means that Jess can't enrol.

We summarise this example in a table.

Passed Maths 1 Passed Stats 1 Allowed to Enrol
True True True
True False True
False True True
False False False

In general, || (OR) is used as shown in this truth table.

$a$$b$$a||b$
T T T
T F T
F T T
F F F

In some places, for example some maths books, you might see the symbol $\lor$ used for the logical operator OR.

Example

Find the truth value of $24\gt 50||44-44=0$.

Answer: $\underbrace{24\gt 50}_{F}||\underbrace{44-44=0}_{T}$ is F||T, which is T. The answer is T.

Practice questions

Find the truth values of the following:

$1+1=2||42\gt 24$
The capital city of Australia is Perth OR Western Sydney University is in Tasmania.
$42\gt 24||24\gt 42$
$1=2||2\le 4$