← IGCSE Computer Science Paper 2

Writing a logic expression from a problem statement

Give each condition a letter (A, B, C), turn key words like AND, OR and NOT into gates, and use brackets to group parts so that X matches the wording of the statement.

Understanding Writing a logic expression from a problem statement in IGCSE Computer Science Paper 2

What it does: Each condition gets a letter. 'AND' links A and B, 'OR' links that group to C, and brackets show the grouping. 'OR' links A and B, and the machine must also be running. Brackets make sure A OR B is worked out before AND C. The key word AND means both conditions must be true, so the AND gate is used. The brackets group A and B together because the statement says either of them, and the result is then combined with C using AND. NOT applies only to condition B, as the wording says. NOT (A AND B) would invert the whole AND result instead.

Common mistakes: The statement says door OR window, so the alarm sounds when either is open. The line should use OR: X = A OR B. The alarm needs both conditions to be true, so the key word AND gives an AND gate. The line should be X = A AND B.

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
An alarm X sounds if the door is open (A) AND the system is switched on (B). Which expression is correct?
X = A AND BX = A OR B
Matches
X = A AND B OR C
↓
The brackets are missing, so it is unclear which gate is worked out first. The statement 'A and B together, or C' needs (A AND B) OR C.
Applying
Meanings
Term
X = (A AND B) OR C
Meaning
Give each condition a letter (A, B, C), turn key words like AND, OR and NOT into gates, and use brackets to group parts so that X matches the wording of the statement.
Practice
X = (A OR B) AND NOT C
Testing
Gaps
X = A B
Check Answer
Spots
2A = door, B = window
3X = A AND B

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

The 'Bear' badge — Forest Guardian, 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. An alarm X sounds if the door is open (A) AND the system is switched on (B). Which expression is correct?
A. X = A AND B ✓
B. X = A OR B
The key word AND means both conditions must be true, so the AND gate is used.
2. What is the first step when writing an expression from a problem statement?
A. Fill in the output column of the truth table
B. Give each condition an input letter such as A, B or C ✓
Start by assigning a letter to each condition. Then turn the key words into gates.
3. A warning light X comes on if the temperature is too high (A) OR the pressure is too high (B), AND the system is armed (C). Which expression matches?
A. X = A OR (B AND C)
B. X = (A OR B) AND C ✓
The brackets group A and B together because the statement says either of them, and the result is then combined with C using AND.
4. A window alarm X sounds if the window is open (A) AND the key is NOT in the panel (B). Which expression is correct?
A. X = A AND (NOT B) ✓
B. X = NOT (A AND B)
NOT applies only to condition B, as the wording says. NOT (A AND B) would invert the whole AND result instead.
5. A safety lock X is on when the door is closed (A) AND either the seat belt is fastened (B) OR the override is on (C). Which expression is correct?
A. X = A AND (B OR C) ✓
B. X = (A AND B) OR C
B OR C is a grouped condition, so it goes in brackets. Without them, C alone could make X true even if the door is open.

Match the Pairs

X = (A AND B) OR C → The alarm sounds if A and B are both 1, or if C is 1 on its own
X = A AND (NOT B) → X is 1 only when A is 1 and B is 0
The alarm sounds if the door is open (A) AND the system is switched on (B), OR if the panic button is pressed (C) → X = (A AND B) OR C
A warning light comes on if the temperature is high (A) OR the pressure is high (B), AND the machine is running (C) → X = (A OR B) AND C
X = A AND B OR C → The brackets are missing, so it is unclear which gate is worked out first. The statement 'A and B together, or C' needs (A AND B) OR C.
X = (A OR B) AND NOT C → NOT C is used, but the statement says C is true (for example, the machine is running). NOT should only be used when the statement says 'not' or 'is off'.

Key Term

X = (A AND B) OR C
Give each condition a letter (A, B, C), turn key words like AND, OR and NOT into gates, and use brackets to group parts so that X matches the wording of the statement.

Fill in the Blanks

1. # A = door open, B = window open X = A AND B
Hint: Type the gate that matches the key word 'and' in the alarm statement.
2. # Alarm if door (A) OR window (B) is open X = A OR B
Hint: Type the gate that matches the key word in the comment, where either condition is enough.
3. # A = door open, B = window locked # Alarm if door open AND window NOT locked X = A AND NOT B
Hint: Type the gate that reverses condition B, as the statement describes.
4. # A = door, B = window, C = key switch # X on if (door OR window) AND key on X = (A OR B) AND C
Hint: Type the symbol that opens the group so the two linked conditions are worked out first.
5. # A = lid shut, B = guard shut, C = override # Runs if lid AND guard shut, or override X = (A AND B) OR C
Hint: Type the input letter given to the override condition.

Spot the Error

Question 1
A # Alarm: door OR window open
B A = door, B = window
C X = A AND B
Line C — The statement says door OR window, so the alarm sounds when either is open. The line should use OR: X = A OR B.
Question 2
A # Alarm: door open AND on
B A = door open, B = system on
C X = A OR B
Line C — The alarm needs both conditions to be true, so the key word AND gives an AND gate. The line should be X = A AND B.
Question 3
A # A guard shut, B stop pressed
B X = A AND B
C # Runs if shut and not pressed
Line B — The statement says the stop button must NOT be pressed, so B needs a NOT gate. The line should be X = A AND (NOT B).
Question 4
A # On if A or B, and not C
B X = (A AND B) AND NOT C
C # A dark, B motion, C override
Line B — The statement says A or B, so the grouped part needs an OR gate, not AND. The line should be X = (A OR B) AND NOT C.
Question 5
A # Buzzer: A, and B or C
B X = (A AND B) OR C
C # X = 1 when buzzer sounds
Line B — The wording says A is needed, together with B or C. The brackets must group B OR C: X = A AND (B OR C).

Student with a class code? Join your class →