Skip to content
IGCSE·Tuition
Computer Science · Lesson

Construct a truth table

A truth table is easy to start and easy to leave incomplete, with a row missing and nobody noticing.

On this page
  1. How do you build the table?
  2. Worked example
  3. The mistake to watch for
  4. Check yourself
  5. Where this leads next

A truth table lists every possible combination of inputs and the output of the expression or circuit for each one. With n inputs there are 2n rows, so the first job is always to count the rows you owe.

This lesson builds on evaluating an expression with parentheses, because each row of a truth table is one evaluation. It is part of the Boolean logic module.

How do you build the table?

  1. Count the inputs and calculate the rows: 2 inputs = 4, 3 inputs = 8, 4 inputs = 16.
  2. Write the input rows in binary counting order, starting at all 0s and ending at all 1s.
  3. Add a working column for each bracket, NOT or gate output.
  4. Fill one column at a time, top to bottom, not one row at a time. This keeps the method steady.
  5. Check the row count at the end.

A quick pattern for the input columns: the right-most input alternates 0, 1, 0, 1. The next one alternates in pairs, 0, 0, 1, 1. The left-most of three inputs goes in fours, 0, 0, 0, 0, 1, 1, 1, 1.

Worked example

Complete the truth table for Q = (A AND B) OR NOT C.

Three inputs, so 23 = 8 rows.

ABCA AND BNOT CQ
000011
001000
010011
011000
100011
101000
110111
111101

Check one row in full: for A = 1, B = 1, C = 1 the working is (1 AND 1) OR NOT 1 = 1 OR 0 = 1. The output column reads 1, 0, 1, 0, 1, 0, 1, 1. It has five 1s and three 0s.

The mistake to watch for

A common slip is to write only the rows that look interesting, or to repeat a row by accident.

Mistaken table for two inputs: rows 00, 01, 11, with the row 10 missing.

The output column then has three entries instead of four, and the table is incomplete.

The correction is to count the rows first and write all the input columns before touching the output. For 2 inputs, always write 00, 01, 10, 11.

Check yourself

1. Complete the truth table for Q = (A OR B) AND NOT (A AND B).

Show answer
ABA OR BA AND BQ
00000
01101
10101
11110

The output is 1 only when the inputs are different.

2. How many rows are needed for four inputs?

Show answer

24 = 16 rows.

3. Give the output column for Q = A AND NOT B, in the order 00, 01, 10, 11.

Show answer

00: 0 AND 1 = 0. 01: 0 AND 0 = 0. 10: 1 AND 1 = 1. 11: 1 AND 0 = 0. Output: 0, 0, 1, 0.

Where this leads next

Next, read a diagram instead of a formula in interpreting a simple logic circuit. The Boolean and number-representation lab can generate small tables for you to compare with your own.

If you build the table correctly in practice but lose rows under time pressure, our teachers can work through your routine in online one-to-one Computer Science tuition.

Questions people ask

How many rows does a truth table need?

The number of rows is 2 raised to the number of inputs. Two inputs need 4 rows, three inputs need 8 rows and four inputs need 16 rows. If your table has fewer rows than this, at least one input combination is missing and the table is incomplete.

Do I need a column for every step?

It is safer to include one. Working columns for each bracket or gate output let you check each step separately. In an exam they also show your method, and a single slip is easier to find than in one crowded output column.

In what order should the input rows go?

Use binary counting order, from 000 up to 111 for three inputs. This way no combination is repeated or missed. Random order makes a missing row very hard to spot, even for you.

Sources

  1. Cambridge IGCSE Computer Science 0478 syllabus page

Updated:

Your next step

If your truth tables are mostly right but one wrong row keeps costing you the answer, a one-to-one teacher can check your method with you and build a routine that does not skip rows.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parents: enquire here

  • 9,000+ students helped through our service
  • 9+ years helping IGCSE students