← IGCSE Computer Science Paper 2

Writing a logic expression from a truth table

To write an expression from a truth table, take each row with output 1 and join its inputs with AND, adding NOT to any input that is 0. Then join those rows with OR.

Understanding Writing a logic expression from a truth table in IGCSE Computer Science Paper 2

What it does: Both inputs are 0 in the row with output 1, so each gets NOT and the two are joined with AND. AND gives 1 only when both inputs are 1. OR would also give 1 for the rows 0,1 and 1,0. An input that is 1 is written as it is. An input that is 0 gets NOT. So A stays as A and B becomes NOT B. X is 1 if any one of the rows matches, so the parts are joined with OR. Only B is 0 in that row, so only B gets NOT. A and C are 1, so they have no NOT.

Common mistakes: A is 0 in this row, so it must be written as NOT A. The row should be NOT A AND B. An output that is 1 only when both inputs are 1 is the AND pattern. OR gives 1 for three of the four rows.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 562–580) and word search (Modules 539–580).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A two-input truth table has X = 1 only in the row A=1, B=1. Which expression matches?
X = A AND BX = A OR B
Matches
X = A AND B (for the row A=1, B=0 with output 1)
↓
B is 0 in this row, so it needs NOT. The correct row is A AND NOT B.
Applying
Meanings
Term
X = (A AND NOT B) OR (NOT A AND B)
Meaning
To write an expression from a truth table, take each row with output 1 and join its inputs with AND, adding NOT to any input that is 0. Then join those rows with OR.
Practice
X = (NOT A AND B AND C) OR (A AND NOT B AND C)
Testing
Gaps
X = A B
Check Answer
Spots
1Table: A=0, B=1 gives X=1
2Row 1 as AND: A AND B

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Zebra' badge — Pattern Matcher, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A two-input truth table has X = 1 only in the row A=1, B=1. Which expression matches?
A. X = A OR B
B. X = A AND B ✓
AND gives 1 only when both inputs are 1. OR would also give 1 for the rows 0,1 and 1,0.
2. A two-input truth table has output X = 0, 1, 1, 0 for the rows 00, 01, 10, 11. Which single gate gives this pattern?
A. XOR ✓
B. OR
XOR is 1 when the inputs are different. OR would give 1 in the last row too, where both inputs are 1.
3. To build an expression from a complex truth table, which rows do you write out?
A. Only the rows where the output is 0
B. Only the rows where the output is 1 ✓
Each row with output 1 becomes one part of the expression. Rows with output 0 are left out.
4. The row A=1, B=0 gives X = 1. How do you write this row?
A. A AND NOT B ✓
B. NOT A AND B
An input that is 1 is written as it is. An input that is 0 gets NOT. So A stays as A and B becomes NOT B.
5. You have written one AND part for each row where X = 1. How do you join these parts together?
A. With OR ✓
B. With AND
X is 1 if any one of the rows matches, so the parts are joined with OR.

Match the Pairs

X = (A AND NOT B) OR (NOT A AND B) → Rows 10 and 01 give output 1. Each row is written with AND and NOT on the 0 input, then the rows are joined with OR.
X = A AND B AND NOT C → The only row with output 1 is A=1, B=1, C=0. The 0 input C gets NOT and all three inputs are joined with AND.
The only row with output 1 is A=0, B=0. Write this row with NOT on both inputs that are 0. → X = NOT A AND NOT B
Output 1 only when A=1 and B=0, and also when A=1 and B=1. Join the two row expressions with OR. → X = (A AND NOT B) OR (A AND B)
X = A AND B (for the row A=1, B=0 with output 1) → B is 0 in this row, so it needs NOT. The correct row is A AND NOT B.
X = (NOT A AND B) AND (A AND NOT B) (for rows 01 and 10 with output 1) → Rows with output 1 must be joined with OR, not AND. The correct expression is (NOT A AND B) OR (A AND NOT B).

Key Term

X = (A AND NOT B) OR (NOT A AND B)
To write an expression from a truth table, take each row with output 1 and join its inputs with AND, adding NOT to any input that is 0. Then join those rows with OR.

Fill in the Blanks

1. X = A AND B
Hint: Output X is 1 only in the row where both inputs are 1. Type the gate that matches this pattern.
2. X = A AND NOT B
Hint: In the row with output 1, input B is 0. Type the gate word that goes in front of an input that is 0.
3. X = (A AND NOT B) OR (NOT A AND B)
Hint: Two different rows give output 1. Type the gate used to join the separate rows together.
4. X = A AND NOT B AND C
Hint: The row with output 1 has A = 1, B = 0 and C = 1. Type the input that needs NOT in front of it.
5. X = (A AND NOT B) OR (NOT A AND B)
Hint: Inside one row, the inputs are combined with the same gate. Type the gate that joins inputs within a single row.

Spot the Error

Question 1
A Table: A=0, B=1 gives X=1
B Row 1 as AND: A AND B
C Only one row has X=1
D X = NOT A AND B
Line B — A is 0 in this row, so it must be written as NOT A. The row should be NOT A AND B.
Question 2
A Only row 1 1 gives X = 1
B This is the OR pattern
C X = A AND B
Line B — An output that is 1 only when both inputs are 1 is the AND pattern. OR gives 1 for three of the four rows.
Question 3
A Rows with X=1: 0 1 and 1 0
B P = NOT A AND B
C Q = A AND NOT B
D X = P AND Q
Line D — Rows with output 1 are joined with OR, not AND. P and Q can never both be true at once, so AND would always give 0.
Question 4
A Row A=1, B=0, C=1 gives X=1
B A is 1, so write A
C B is 0, so write B
D C is 1, so write C
E Row: A AND NOT B AND C
Line C — An input that is 0 in the row must be written with NOT. It should say: B is 0, so write NOT B.
Question 5
A Table: X=1 only when A=0,B=0
B Row 0 0: both inputs are 0
C Write it: NOT A OR NOT B
D X = NOT A AND NOT B
Line C — Inputs within one row are joined with AND, not OR. The row should be written NOT A AND NOT B.

Student with a class code? Join your class →