Singapore O-Level / G3 Computing
Logic Gates and Truth Tables for O-Level / G3 Computing
A truth table lists every possible combination of inputs to a logic circuit and the output each combination produces. Logic gates are the building blocks of those circuits: AND, OR, NOT, NAND, NOR and XOR each work on inputs of 0 or 1 and give an output of 0 or 1.
This guide covers Module 1.3 Logic Gates of G3 Computing (Syllabus K349): all six gates, 3-input truth tables, converting between circuit, Boolean statement and truth table, the Boolean laws including the distributive law and De Morgan’s theorem, system problems, and exam-style questions with full worked answers.
Logic gates and truth tables at a glance
- Syllabus: G3 Computing (Syllabus K349), Module 1.3 Logic Gates, learning outcomes 1.3.1 to 1.3.5.
- Gates and notation: AND is A · B, OR is A + B, NOT is A, NAND is A · B, NOR is A + B and XOR is A ⊕ B. Learn each symbol and truth table.
- Truth tables: up to 3 inputs, so at most 8 rows, counted in binary from 000 to 111.
- Conversions: circuit diagram, Boolean statement and truth table, in any direction.
- Laws to memorise: the distributive law and De Morgan’s theorem, plus the associative law. Learning outcome 1.3.4 requires all three, and none of them is printed on the formulae page.
- Applied skill: solving system problems with combinations of gates (maximum 3 inputs).
On this page
- What logic gates and truth tables are
- The six logic gates: symbols, expressions and truth tables
- How to build a truth table for a 3-input circuit
- Boolean laws: associative, distributive and De Morgan’s theorem
- Solving a system problem: from words to circuit
- Exam-style practice questions with worked answers
- Common mistakes with logic gates and truth tables
- Frequently asked questions
What logic gates and truth tables are
A logic gate takes one or more binary inputs and produces one binary output. Every input and output is either 1 (true, on) or 0 (false, off). Connect gates together and you have a logic circuit.
Module 1.3 Logic Gates of G3 Computing (Syllabus K349) asks you to describe a circuit in three ways and move between them: a circuit diagram, a Boolean statement and a truth table.
| Outcome | What you must be able to do |
|---|---|
| 1.3.1 | Represent logic circuits as circuit diagrams or Boolean statements and convert between the two |
| 1.3.2 | Construct the truth table for a given circuit (maximum 3 inputs) and vice versa |
| 1.3.3 | Draw symbols and construct truth tables for AND, OR, NOT, NAND, NOR and XOR |
| 1.3.4 | Manipulate Boolean statements using the associative and distributive properties and De Morgan’s theorem |
| 1.3.5 | Solve system problems using combinations of logic gates (maximum 3 inputs) |
The notation used in this guide
This guide follows the notation page in G3 Computing (Syllabus K349): AND is written A · B, OR is A + B, XOR is A ⊕ B and NOT A is A. A bar over a letter or expression means NOT, and a long bar covers everything under it.
A · B: the short bar covers A only, so A is inverted first and the result is combined with B by an AND gate.A · B: the long bar covers A · B, so the AND is worked out first and the whole result is inverted. This is a NAND gate.- A bar groups everything under it, so no brackets are needed under a bar.
- AND is worked out before OR, the same way multiplication comes before addition, so
A · B + Cmeans(A · B) + C. Add brackets whenever they make the order clearer.
For where this module sits in the whole course, see our guide to every G3 Computing topic.
The six logic gates: symbols, expressions and truth tables
Learning outcome 1.3.3 asks you to draw each gate symbol and build its truth table.
| Gate | Symbol shape | Boolean expression | Output is 1 when |
|---|---|---|---|
| AND | D shape: flat input side, rounded output side | A · B |
both inputs are 1 |
| OR | Curved input side, pointed output side | A + B |
at least one input is 1 |
| NOT | Triangle with a small circle at its tip; one input only | A |
the input is 0 |
| NAND | AND shape with a small circle on the output | A · B |
at least one input is 0 |
| NOR | OR shape with a small circle on the output | A + B |
both inputs are 0 |
| XOR | OR shape with an extra curved line just before the inputs | A ⊕ B |
the two inputs are different |
The small circle, often called a bubble, always means invert. NAND is an AND gate followed by a NOT gate. NOR is an OR gate followed by a NOT gate.
Truth tables for the two-input gates
Each output column is headed by the gate’s Boolean expression. From left to right the outputs are AND, OR, NAND, NOR and XOR.
| A | B | A · B | A + B | A · B | A + B | A ⊕ B |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
Truth table for NOT
| A | A |
|---|---|
| 0 | 1 |
| 1 | 0 |
Memory trick: read each output column from top to bottom as a 4-digit code. AND is 0001, OR is 0111, NAND is 1110, NOR is 1000 and XOR is 0110. NAND is AND with every digit flipped, and NOR is OR with every digit flipped.
How to build a truth table for a 3-input circuit
Each extra input doubles the number of rows. One input gives 2 rows, two inputs give 4 rows, and three inputs give 2 × 2 × 2 = 8 rows. The syllabus caps circuits at 3 inputs, so 8 rows is the most you will need.
- Write the inputs A, B and C as the first three columns.
- Fill the rows by counting in binary from 000 to 111. Column C alternates every row (0, 1, 0, 1…), B changes every two rows, and A changes every four rows. If binary counting feels shaky, revise binary to denary conversion first.
- Add one working column for each gate inside the circuit.
- Fill the final output column from the working columns, one row at a time.
Worked example: circuit to Boolean statement to truth table
Circuit in words: inputs A and B feed an AND gate. Input C feeds a NOT gate. The outputs of the AND gate and the NOT gate feed an OR gate, whose output is X.
Boolean statement: X = (A · B) + C
| A | B | C | A · B | C | X |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 1 |
X is 1 whenever C is 0, and also on the last row where A and B are both 1.
Truth table to Boolean statement
Outcome 1.3.2 also works in reverse. Use this method:
- Find every row where the output is 1.
- For each of those rows, write an AND term that is 1 on that row only. Use the plain letter where the input is 1 and the letter with a bar over it where the input is 0.
- Join the terms with OR.
Example: a 2-input table has X = 1 only on the rows A = 0, B = 1 and A = 1, B = 0. The terms are A · B and A · B, so X = A · B + A · B. That is exactly the XOR pattern 0110, so the same circuit can be drawn as one XOR gate: X = A ⊕ B.
Boolean statement to circuit diagram
Work from the inside out: brackets and anything under a bar come first. Each operator becomes one gate, and the operator applied last is the gate that produces X. For X = A + B · C: draw an OR gate for A and B, add a NOT gate after it (or draw both as one NOR gate), then feed that output and C into an AND gate.
Boolean laws: associative, distributive and De Morgan’s theorem
Learning outcome 1.3.4 asks you to manipulate Boolean statements using the associative and distributive properties and De Morgan’s theorem. The formulae page in G3 Computing (Syllabus K349) lists annulment, identity, idempotent, self-inverting, complement, commutative and absorption rules. The distributive law, De Morgan’s theorem and the associative law are absent from that page, so you must memorise them. Learn both forms of the distributive law and both forms of De Morgan’s theorem.
| Law | Form 1 | Form 2 |
|---|---|---|
| Associative | (A · B) · C = A · (B · C) |
(A + B) + C = A + (B + C) |
| Distributive | A · (B + C) = A · B + A · C |
A + B · C = (A + B) · (A + C) |
| De Morgan’s theorem | A · B = A + B |
A + B = A · B |
- Associative: you can regroup gates of the same type. A 3-input AND can be built from two 2-input AND gates in either order.
- Distributive, form 1 (AND over OR): expand
A · (B + C)intoA · B + A · C, as you would in algebra. Read from right to left, it lets you factorise a common letter out of two terms. - Distributive, form 2 (OR over AND):
A + B · Cexpands to(A + B) · (A + C). Ordinary algebra has no rule like this, so practise it separately. - De Morgan’s theorem: when a long bar covers a whole expression, break it into a short bar over each letter and swap · with +. Many students remember it as “break the bar, change the sign”.
Worked simplification 1: De Morgan’s theorem
Simplify X = A + B + A · B.
X = A + B + A · B = A · B + A · B De Morgan's theorem = A · B + A · B two bars cancel = A · (B + B) distributive (factorise A) = A · 1 complement: B + B = 1 = A identity: A · 1 = A
Check with a truth table:
| A | B | A + B | A · B | X |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 1 | 1 |
The X column matches A on every row, so the whole circuit reduces to a single wire from input A.
Worked simplification 2: distributive law, AND over OR
Simplify X = A · (A + B).
X = A · (A + B) = A · A + A · B distributive: A · (B + C) = A · B + A · C = 0 + A · B complement: A · A = 0 = A · B + 0 commutative = A · B identity: A · B + 0 = A · B
Check with a truth table:
| A | B | A + B | X = A · (A + B) | A · B |
|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 | 1 |
The X column matches A · B on every row, so one AND gate replaces the original three gates.
Worked simplification 3: distributive law, OR over AND
Simplify X = A + A · B.
X = A + A · B = (A + A) · (A + B) distributive: A + B · C = (A + B) · (A + C) = 1 · (A + B) complement: A + A = 1 = (A + B) · 1 commutative = A + B identity: (A + B) · 1 = A + B
Check with a truth table:
| A | B | A · B | X = A + A · B | A + B |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 |
The X column matches A + B on every row, so one OR gate replaces the original three gates. Finish every simplification with a quick truth table like these.
Solving a system problem: from words to circuit
Learning outcome 1.3.5 asks you to solve system problems: a short real-world description that you turn into a logic circuit. Follow the same steps every time.
Scenario: a home alarm sounds when the system is armed and either the door or the window is open.
- Define every input and the output. S = 1 when the system is armed. D = 1 when the door is open. W = 1 when the window is open. X = 1 when the alarm sounds.
- Translate the key words. “and” becomes an AND gate. “either … or” becomes an OR gate, provided both being open should also trigger the output. Here, door and window both open should still sound the alarm, so OR is correct. “not” and “unless” usually point to a NOT gate.
- Write the Boolean statement:
X = S · (D + W) - Describe the circuit: D and W feed an OR gate. The OR output and S feed an AND gate. The AND output is X.
- Build the truth table and check it against the words.
| S | D | W | D + W | X |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 |
The alarm sounds on the last three rows only: armed, with at least one opening. That matches the scenario.
The distributive law (AND over OR) gives an equivalent answer, X = S · D + S · W, which uses three gates instead of two.
Exam-style practice questions with worked answers
Try each question on paper before reading the answer. Inputs are always listed in binary order from 000 to 111.
Question 1
Complete the truth table for X = (A ⊕ B) · C.
| A | B | C | A ⊕ B | X |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 |
Working: A ⊕ B is 1 when A and B differ (rows 3 to 6). X is 1 only where A ⊕ B is 1 and C is 1, which is rows 011 and 101.
Question 2
Inputs A and B feed a NOR gate. The NOR output and input C feed an XOR gate, whose output is X. Write the Boolean statement and complete the truth table.
Boolean statement: X = A + B ⊕ C
| A | B | C | A + B | X |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 1 |
Working: NOR is 1 only when A and B are both 0 (the first two rows). XOR then gives 1 wherever the NOR output and C differ.
Question 3
Use De Morgan’s theorem to simplify X = A · B · A, stating the law used at each step.
X = A · B · A = (A + B) · A De Morgan's theorem = (A + B) · A two bars cancel = A · (A + B) commutative = A absorption: A · (A + B) = A
Check: when A = 0, the final AND with A gives X = 0. When A = 1, A · B = 0, so the long bar gives 1, and 1 · 1 = 1. X always equals A.
Question 4
A water pump switches on (P = 1) when the tank is not full and either the manual switch or the timer is on. F = 1 means the tank is full, M = 1 means the manual switch is on and T = 1 means the timer is on. Write the Boolean statement and give the output column of the truth table.
Boolean statement: P = F · (M + T)
Working: F is 1 only on the first four rows, where F = 0. Of those, M + T is 0 only on row 000. So P is 1 on rows 001, 010 and 011, and 0 everywhere else.
Output column, rows 000 to 111: 0, 1, 1, 1, 0, 0, 0, 0.
Question 5
Use a truth table to show that A · B = A + B.
| A | B | A · B | A · B | A | B | A + B |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
Working: the A · B column and the A + B column are both 1, 1, 1, 0, so the two expressions are equal for every input. This is form 1 of De Morgan’s theorem.
Common mistakes with logic gates and truth tables
- Missing or repeated rows. A 3-input table needs exactly 8 rows. Count in binary from 000 to 111 and every combination appears once.
- Mixing up OR and XOR. The two gates differ only on the row where both inputs are 1. OR gives 1 there and XOR gives 0. In system problems, decide what should happen when both conditions are true.
- Applying De Morgan’s theorem halfway. Breaking the bar without swapping · and + gives a wrong answer.
A + BbecomesA · B, with the sign changed. - Forgetting the second distributive form.
A + B · Cexpands to(A + B) · (A + C). Ordinary algebra has no rule like this, so it is easy to miss in a simplification. - Misreading the length of a bar.
A · Bis a NAND gate.A · Bis the same as a NOR gate. Copy bar lengths carefully from the question. - Dropping brackets.
S · (D + W)andS · D + Wgive different truth tables. Write brackets every time the OR must be worked out first. - Skipping the working columns. Add a column for each gate before the output column. It makes errors easy to spot and shows the examiner your method.
- Leaving inputs undefined in system problems. State what 1 means for each input and for the output before writing any expression.
- Skipping the final check. A short truth table confirms a simplified statement matches the original.
If you want a tutor to mark your truth tables and simplifications every week, our G3 Computing tuition covers Module 1.3 alongside the rest of the syllabus.
Frequently asked questions
How many rows does a truth table with 3 inputs have?
A truth table with 3 inputs has 8 rows, because each input can be 0 or 1 and 2 × 2 × 2 = 8. List the rows in binary order from 000 to 111 so none are missed.
Which logic gates does G3 Computing (Syllabus K349) cover?
Module 1.3 Logic Gates covers six gates: AND, OR, NOT, NAND, NOR and XOR. You must draw each symbol and construct its truth table.
Are De Morgan’s theorem and the distributive law on the G3 Computing formulae page?
No. The G3 Computing (Syllabus K349) formulae page lists annulment, identity, idempotent, self-inverting, complement, commutative and absorption rules. Learning outcome 1.3.4 also requires De Morgan’s theorem (A · B = A + B and A + B = A · B) and the distributive law (A · (B + C) = A · B + A · C and A + B · C = (A + B) · (A + C)), so memorise both, along with the associative law.
What is the difference between OR and XOR?
OR outputs 1 when at least one input is 1. XOR outputs 1 only when the inputs are different, so it gives 0 when both inputs are 1.
Is O-Level Computing the same as G3 Computing?
Yes. From 2027 the subject is G3 Computing (Syllabus K349) under the Singapore-Cambridge Secondary Education Certificate (SEC), and K349 replaces O-Level Computing 7155. Module 1.3 Logic Gates has the same learning outcomes and formulae page in both.
Sources and syllabus reference
Master logic gates with weekly G3 Computing tuition
Book a free trial lesson of weekly tuition for G3 Computing (Syllabus K349) at Computhink@ToaPayohLibrary (6 Toa Payoh Central) or online. Computhink Academy has been teaching since 2015, and your tutor will work through truth tables, Boolean laws and system problems with you.