Skip to main content

Logic Gates & Truth Tables: The Building Blocks of the ALU

By Prof. David Chen, CS Examiner·Updated April 18, 2026
A complex logic circuit diagram showing inputs flowing through AND, OR, and NOT gates.

How do you quickly fill out the 8 output rows for an XOR (Exclusive OR) gate?

An XOR gate is the 'Difference Detector'. Just look at the two inputs. If the inputs are DIFFERENT (0, 1 or 1, 0), the XOR gate outputs a 1. If the inputs are EXACTLY THE SAME (0, 0 or 1, 1), the XOR gate outputs a 0. It is 'exclusive' because it does not allow both inputs to be 1.

Logic gates are actual physical microscopic transistors inside the CPU that control the flow of electricity based on boolean logic (True/False or 1/0). In Paper 1, you will routinely be asked to trace the outputs through a complex circuit. This guide from our Ultimate O-Level Computer Science Guide gives you the exact rules.

1. The Core Three (AND, OR, NOT)

Every other piece of logic in the computer is built from these three bases.

  • NOT Gate (Inverter): Has only ONE input. It flips the bit. If 1 goes in, 0 comes out. If 0 goes in, 1 comes out. Draws as a triangle with a tiny circle at the tip.
  • AND Gate: Takes two inputs. Outputs 1 ONLY IF Input A and Input B are both 1. Otherwise, it outputs 0. Draws as a 'D' shape.
  • OR Gate: Takes two inputs. Outputs 1 if AT LEAST ONE of the inputs is 1. It also outputs 1 if both are 1. Draws as a curved shield shape.

2. The Inverted Gates (NAND, NOR, XOR)

When you stick a NOT gate at the end of an AND or OR gate, you get their inverted cousins.

NAND Gate (NOT-AND)

It does the exact opposite of an AND gate. It outputs a 0 ONLY when both inputs are 1. In all other scenarios, it outputs a 1.

NOR Gate (NOT-OR)

The exact opposite of an OR gate. It outputs a 1 ONLY when both inputs are 0. If it spots a single '1' anywhere in the inputs, it slams shut and outputs a 0.

XOR Gate (Exclusive-OR)

The "Difference Detector". It outputs a 1 if the inputs are different (e.g., 1 and 0). If the inputs are the same, it outputs 0. It is basically the standard OR gate, but it strictly excludes the "both inputs are 1" scenario.

💡 Tutor's Tip
Drawing Marks: In the exam, when drawing NAND or NOR gates, you must make sure the tiny circle at the tip is clearly visible. If you draw an AND gate without the circle, you get zero marks for that gate in a circuit drawing.

3. The Intermediary Column Trick for Truth Tables

A logic circuit with 3 inputs (A, B, C) will require you to fill out an 8-row truth table. Many students try to trace the 0s and 1s through the whole circuit in their head, get confused by row 6, and fail the question.

Always use Working Columns!

If a circuit combines (A AND B) into an OR gate with C. Do not do it all at once. Create a blank column in your exam paper with a pencil. Label it 'Z'. Let Z equal the output of (A AND B). Fill out all 8 rows for Z first. Once you have Z, you easily compare the Z column with the C column through the final OR gate to get the final answer. Break the complex circuit into smaller, safe steps.

Prof. David Chen📋 From the Desk of Prof. David Chen
If you are asked to represent a logic circuit using a logic statement, you must use brackets to show the order of operations, just like in math. "X = (A AND B) OR (NOT C)" is correct. Writing "X = A AND B OR NOT C" is ambiguous and will lose you the mark.

Frequently Asked Questions

What is the difference between an AND gate and an OR gate?
AND requires all inputs to be 1 to output 1. OR requires only one input to be 1 to output 1.
How does an XOR gate work?
Exclusive-OR outputs a 1 only when its inputs are DIFFERENT from each other.
What does the little circle on a NAND or NOR gate represent?
The small circle stands for a NOT inversion. It flips the final result.
How many rows are in a 3-input truth table?
8 rows (calculated as 2 to the power of 3).

Stop Guessing, Start Scoring

Get instant access to 500+ CAIE-aligned practice questions, worked solutions, and AI-powered mock exams across all O-Level subjects.

Related Computer Science Articles