📘 Paper 2 · Topic 9: Boolean Logic
9.1 Boolean Logic: AND, OR, NOT
Cambridge IGCSE Computer Science 0478 · ~15 min read · ✓ Free Lesson

Boolean Logic

Boolean logic deals with values that can only be TRUE or FALSE (1 or 0). It forms the foundation of all digital circuits and computers. All computer decisions are ultimately made using combinations of AND, OR, and NOT operations.

The Three Basic Logic Gates

NOT Gate (Inverter)

A NOT gate takes ONE input and outputs the OPPOSITE. If the input is 1 (TRUE), the output is 0 (FALSE), and vice versa.

Input ANOT A (Output)
01
10
NOT gate symbol: A ——|◯— Q
Where ◯ indicates inversion

AND Gate

An AND gate takes TWO (or more) inputs and outputs 1 ONLY if ALL inputs are 1. Think of it as: "both must be true".

Input AInput BA AND B (Output)
000
010
100
111
AND gate: A ─┐
            D─── Q
B ─┘
(Output is 1 only when A=1 AND B=1)

OR Gate

An OR gate takes TWO (or more) inputs and outputs 1 if AT LEAST ONE input is 1. Think of it as: "at least one must be true".

Input AInput BA OR B (Output)
000
011
101
111

Combining Gates

Real circuits combine multiple gates. The output of one gate can feed into another.

NOT AND = NAND

A NAND gate is an AND gate followed by a NOT. Output is 0 ONLY when both inputs are 1.

ABA AND BNOT(A AND B)
0001
0101
1001
1110

NOT OR = NOR

A NOR gate is an OR gate followed by a NOT. Output is 1 ONLY when both inputs are 0.

ABA OR BNOT(A OR B)
0001
0110
1010
1110

Using Boolean Logic in Programs

The same AND, OR, NOT operators used in logic gates are used in pseudocode conditions:

IF age >= 18 AND hasID = TRUE THEN
    OUTPUT "Entry allowed"
ENDIF

IF score > 100 OR score < 0 THEN
    OUTPUT "Invalid score"
ENDIF

IF NOT memberLoggedIn THEN
    OUTPUT "Please log in"
ENDIF
Exam tip: Learn the truth tables for AND, OR, and NOT by heart — they come up every year. AND = output 1 only when ALL inputs are 1. OR = output 0 only when ALL inputs are 0. NOT = always the opposite. When building a truth table with 2 inputs, you always have exactly 4 rows (00, 01, 10, 11).
⚠️ Common Mistakes
  • Confusing AND and OR — AND requires ALL inputs to be 1; OR only needs ONE input to be 1
  • Forgetting that NOT(0) = 1 and NOT(1) = 0 (not 0 and not 1)
  • Drawing truth tables in the wrong order — always go 00, 01, 10, 11 for inputs A and B
  • Mixing up NAND and NOR — NAND is NOT(A AND B), NOR is NOT(A OR B)
Video coming soon
Click slide or press arrow keys to navigate
✍️

Worksheet — Boolean Logic

4 questions · 9 marks

Q1Complete the truth table for NOT A AND B (i.e., (NOT A) AND B). [4]
✅ Mark scheme
A=0,B=0: NOT A=1, Output=0 [1]; A=0,B=1: NOT A=1, Output=1 [1]; A=1,B=0: NOT A=0, Output=0 [1]; A=1,B=1: NOT A=0, Output=0 [1]. Only row 2 (0,1) gives output 1.
Q2State the output of an AND gate when A=1 and B=0. Explain why. [2]
✅ Mark scheme
Output = 0 [1]. An AND gate only outputs 1 when ALL inputs are 1. Since B=0, not all inputs are 1, so the output is 0 [1].
Q3Which gate outputs 0 ONLY when both inputs are 0? [1]
✅ Mark scheme
OR gate [1]. An OR gate outputs 0 only when all inputs are 0; it outputs 1 for any other combination (01, 10, 11).
Q4Write a pseudocode IF statement that allows access if isAdmin is TRUE OR the user's level is >= 5. [2]
✅ Mark scheme
IF isAdmin = TRUE OR level >= 5 THEN [2] (1 mark for OR condition, 1 mark for correct structure with THEN/ENDIF implied)
Quiz — Boolean Logic
Q 1 of 7
Score
/ 7
Click to reveal
TermDefinition
🎯

Mini Test — Boolean Logic

10 minutes · mixed marks

← 8.5 String Handling Topic 9: Boolean Logic Next: 9.2 Logic Expressions →