Logic Gates and Truth Tables in IGCSE Computer Science
At a school science fair, students build an alarm for a display case. It should sound if the door opens or the case is moved, but it should stay silent while a teacher has switched on maintenance mode.
What happens if the door is open and maintenance mode is on? A truth table lets you check that case and every other possible combination. In this example, you’ll use three gates from the Cambridge IGCSE Computer Science syllabus — AND, OR and NOT. Cambridge IGCSE Computer Science syllabus, Section 10
What do AND, OR and NOT do?
A logic gate takes one or more binary inputs and produces a binary output. Each value is either 0 or 1.
| Gate | How it works | Example |
|---|---|---|
| AND | Outputs 1 only when both inputs are 1. | 1 AND 0 = 0 |
| OR | Outputs 1 when at least one input is 1. It also outputs 1 when both inputs are 1. | 1 OR 1 = 1 |
| NOT | Flips a single input. | NOT 1 = 0 |
Step 1. Turn the alarm rule into an expression
Give each input a letter and define what 1 means.
| Input | Meaning when it equals 1 |
|---|---|
D | The display-case door is open. |
M | The case has moved. |
T | Maintenance mode is on. |
The alarm needs at least one trigger, so start with D OR M. It can sound only when maintenance mode is off, which is NOT T. Both parts must be true, so join them with AND.
Alarm = (D OR M) AND (NOT T)
The brackets show which operations to work out before the final AND. If you draw the circuit, connect D and M to an OR gate, send T through a NOT gate, and connect those two outputs to an AND gate.
Step 2. Complete the truth table one column at a time
Three inputs give you 2 × 2 × 2 = 8 combinations. List them in binary order from 000 to 111 so each combination appears once.
| D | M | T | D OR M | NOT T | Alarm |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 |
Take the row D = 1, M = 0, T = 1. The door is open, so D OR M gives 1. Maintenance mode is on, so NOT T gives 0. The final gate receives 1 AND 0, and the alarm stays silent.
Now scan the table for a quick check. Every row where T = 1 should have an alarm output of 0.
Try it yourself
The students change the rule. Now the alarm sounds only when both the door opens and the case moves, and maintenance mode is off.
Write the new Boolean expression.
What is the alarm output for
D = 1,M = 0,T = 0?Which input combination makes the alarm sound?
Answers — 1. (D AND M) AND (NOT T). 2. 0, because the case hasn’t moved. 3. D = 1, M = 1, T = 0.
Frequently asked questions
How do I remember the order of the eight rows?
Write the inputs as binary numbers from 000 to 111. The left column changes every four rows, the middle column every two rows, and the right column changes every row.
Why add extra columns for the gates?
An intermediate column lets you check one gate at a time. In the alarm example, if the final answer looks wrong, you can check the trigger and maintenance conditions separately to find the mistake.
For help planning revision across subjects, read TheTuitionE’s IGCSE exam preparation guide for UAE parents.
If your child understands individual gates but gets stuck when they’re combined, bring a recent truth-table question to a free TheTuitionE demo class.
