Truth tables

Computer Science · Boolean logic. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science topics

The idea

A truth table lists every possible combination of inputs to a logic circuit and the output for each one. With 2 inputs there are 4 rows. With 3 inputs there are 8 rows. The rows are written in binary counting order, from 000 up to 111.

To complete a table from an expression or a circuit, do not jump straight to the final output. Work out the output of each gate or bracket first, as an extra working column, and then combine those results.

For a problem statement, first turn the words into an expression, or mark the rows where the stated conditions are met, taking care with what 1 and 0 mean for each input.

Rules to remember

Common mistake

Students try to do a whole row in their head and lose a NOT on the way. Write the intermediate values for each row, and use XOR = 0 when both inputs are 1.

Worked example

In the eight-row truth table for X = (A OR NOT B) AND C, in how many rows is X = 1?

  1. X is an AND, so C must be 1 and (A OR NOT B) must be 1.
  2. A OR NOT B is 1 for A,B = 0,0 (NOT B = 1), 1,0 and 1,1. It is 0 only for A,B = 0,1.
  3. With C = 1 this gives the rows ABC = 001, 101 and 111.
  4. Every row with C = 0 gives X = 0, so there are no more.

Answer: 3 rows

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

← Logic circuits and logic expressionsTake a Computer Science test