Boolean logic
Logic gates and truth tables
The six logic gates, NOT, AND, OR, NAND, NOR, and XOR, with their symbols and truth tables.
Examples use Cambridge pseudocode for the 2026–2028 syllabus.
Gates make decisions with 1s and 0s
A logic gate is an electronic component that takes one or two binary inputs and produces one binary output. 1 means on (TRUE), 0 means off (FALSE). Every calculation a CPU does is built from millions of these gates.
A truth table lists every possible combination of inputs and the output for each. With 2 inputs there are 4 rows; with 3 inputs there are 8.
Try every gate
Pick a gate, then click the inputs (or a row of the truth table). Highlighted wires carry a 1.
| A | Out |
|---|---|
| 0 | 1 |
| 1 | 0 |
The rules in words
| Gate | Output is 1 when... | Expression |
|---|---|---|
| NOT | the input is 0 (it flips the input) | X = NOT A |
| AND | both inputs are 1 | X = A AND B |
| OR | at least one input is 1 | X = A OR B |
| NAND | NOT AND: the inputs are not both 1 | X = A NAND B |
| NOR | NOT OR: neither input is 1 | X = A NOR B |
| XOR | the inputs are different | X = A XOR B |
Exam tip. A small circle (bubble) on a gate's output means NOT. That is the only difference between AND and NAND, or OR and NOR.
Check yourself
Which gate outputs 0 only when both inputs are 1?Show answer
NAND.
What is 1 XOR 1?Show answer
0: the inputs are the same.
How many rows does a truth table with 3 inputs need?Show answer
2³ = 8 rows.
References used to build these lessons
We used these official documents as references when building this course's lessons. They are the sources for the syllabus structure and course requirements.
Cambridge International · 2210 · Exams 2026–2028