Skip to content
Cambridge IGCSE0984

Boolean logic

Computer Science 0984 Chapter Notes

Last updated November 2026

ShareWhatsAppPost

Boolean logic notes as a printable PDF.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Boolean logic notes as text: skim, search, and jump between subtopics.

~13 min read

1. NOT, AND and OR gates

Every gate has its own standard symbol. Draw the symbol from the syllabus.

A NOT gate has one input and gives the opposite value: 1 becomes 0 and 0 becomes 1. All the other gates have two inputs.

An AND gate outputs 1 only when both inputs are 1. An OR gate outputs 1 when at least one input is 1.

X = NOT A

X = A AND B

X = A OR B

Examiner insight

“Some candidates need to take more care when drawing logic gates to make sure each gate has its own distinctive shape, for example, NOR and XOR gates shouldn’t have straight sides with curved backs, as this could confuse them with NOT gates.” “Circles or text-based logic circuits are not enough to demonstrate understanding and the correct symbols must be used.”

Worked example 12 marks

Complete the truth table for the logic expression X = NOT A OR B.

ABX
00
01
10
11
  1. 1

    NOT A: 1, 1, 0, 0 for the four rows [1]

  2. 2

    X = (NOT A) OR B: 1, 1, 0, 1 [1]

2. NAND, NOR and XOR gates

A NAND gate is an AND gate followed by NOT. Its output is 0 only when both inputs are 1.

A NOR gate is an OR gate followed by NOT. Its output is 1 only when both inputs are 0.

An XOR (EOR) gate outputs 1 only when its two inputs are different. With inputs 1 and 1 an OR gate gives 1 but an XOR gate gives 0.

X = A NAND B

X = A NOR B

X = A XOR B

Examiner insight

“The most common incorrect gate given was a NOR gate given in place of the XOR gate.” “Some candidates drew a circle at the right point of the XOR gate. This turns the gate into an XNOR gate, which is incorrect.”

Worked example 12 marks

A two-input OR gate and a two-input XOR gate both have the inputs A = 1 and B = 1. State the output of each gate.

  1. 1

    OR gate: output 1, because at least one input is 1 [1]

  2. 2

    XOR gate: output 0, because the two inputs are not different [1]

3. Drawing a circuit from an expression

Build the circuit gate by gate from the expression, working out the brackets first. Do not simplify the expression.

The mark scheme gives one mark for each correct gate, with its correct inputs. A NOT is a gate of its own.

The gates for X = (A NAND NOT B) XOR (A NOR C) are:

``` G1 ← NOT B G2 ← A NAND G1 G3 ← A NOR C X ← G2 XOR G3 ```

Examiner insight

“A common error was mixing up the B OR NOT C and drawing NOT (B OR C) instead.” “Candidates who constructed a logic circuit directly from the given logic expression without attempting to simplify or otherwise alter any of the logic gates generally achieved the best marks.”

Worked example 15 marks

Consider the logic expression:

Z = NOT (B OR NOT C) XOR (A NAND C)

Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two inputs. Do not simplify the logic expression.

  1. 1

    gate 1: `NOT C` [1]

  2. 2

    gate 2: `B OR` (output of gate 1) [1]

  3. 3

    gate 3: `NOT` (output of gate 2) [1]

  4. 4

    gate 4: `A NAND C` [1]

  5. 5

    gate 5: output of gate 3 `XOR` output of gate 4, giving Z [1]

4. Completing a truth table from an expression

A three-input truth table has eight rows, from 000 to 111. Use a working column for each gate, then combine the columns. Check the last column against the original expression, not against your own circuit.

Marks go by the number of correct outputs: four marks for eight correct outputs, three for six or seven, two for four or five, one for two or three.

Examiner insight

“A small number of candidates gave a response that was the exact opposite to the expected answer suggesting either an extra NOT had been applied or a NOT had been missed.” “Use of the original logic expression is recommended to answer this question.”

Worked example 14 marks

Consider the logic expression:

X = (A NAND NOT B) XOR (A NOR C)

Complete the truth table from the given logic expression.

ABCX
000
001
010
011
100
101
110
111
  1. 1

    `A NAND NOT B` by row: 1, 1, 1, 1, 0, 0, 1, 1

  2. 2

    `A NOR C` by row: 1, 0, 1, 0, 0, 0, 0, 0

  3. 3

    XOR the two columns: X = 0, 1, 0, 1, 0, 0, 1, 1 (eight correct outputs) [4]

5. Writing an expression from a circuit or statement

Name each gate and its inputs, then join the parts with brackets. A circuit with three inputs and one output gives an expression such as `(A XOR B) OR (B AND NOT C)`.

The mark scheme gives one mark for each bracketed part, such as A XOR B and B AND NOT C, and one for the correct expression. In a statement, "and", "or" and "not" give AND, OR and NOT.

Examiner insight

“The most common error was the inputs of the AND gate for A AND T being A AND NOT T.”

Worked example 13 marks

A greenhouse fan F switches on when the temperature sensor T is 1 and the window sensor W is not 1, or when the manual switch M is 1. Write the logic expression for F.

  1. 1

    the first condition: T AND NOT W [1]

  2. 2

    the second condition, M, is joined with OR [1]

  3. 3

    correct expression: F = (T AND NOT W) OR M [1]

6. Writing an expression from a truth table

Take each row whose output is 1. Write the AND of the inputs for that row, with NOT on any input that is 0.

Join the rows with OR. Check the expression by working out its truth table again.

Worked example 13 marks

The truth table has inputs A and B and output X. Write a logic expression for X.

ABX
000
011
101
110
  1. 1

    rows with X = 1: A = 0, B = 1 and A = 1, B = 0 [1]

  2. 2

    row terms: NOT A AND B, and A AND NOT B [1]

  3. 3

    X = (NOT A AND B) OR (A AND NOT B). A XOR B has the same truth table. [1]

Recap

  • NOT has one input. Every other gate has two.
  • AND: 1 only if both inputs are 1. OR: 1 if at least one input is 1.
  • NAND and NOR are AND and OR followed by NOT.
  • XOR: 1 only if the inputs are different.
  • Draw the circuit from the expression without simplifying. One mark per gate.
  • A three-input truth table has eight rows. Marks go by the number of correct outputs.
  • From a truth table: AND the inputs in each row with output 1, then OR the rows.

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. State the number of inputs of a NOT gate. State its output when the input is 1.2 marks
    Answer
    1. One input. The input 1 gives the output 0.

    Trap: NOT is the only gate with a single input; the others have two.

  2. State the output of an AND gate and the output of an OR gate when both have the inputs 1 and 0.2 marks
    Answer
    1. AND gives 0, as only one input is 1. OR gives 1, as at least one input is 1.

    Trap: AND and OR swapped.

  3. State the output of a NAND gate when both inputs are 1. Give a reason.2 marks
    Answer
    1. The output is 0: AND gives 1 and the NOT reverses it.

    Trap: Reading NAND as AND gives 1.

  4. Give the output of a NOR gate for the input pairs 00, 01, 10 and 11, in that order.2 marks
    Answer
    1. NOR is OR followed by NOT: OR gives 0, 1, 1, 1.
    2. X = 1, 0, 0, 0.

    Trap: The OR outputs 0, 1, 1, 1 are the exact opposite of the NOR outputs.

  5. A two-input gate outputs 1 only when its inputs are different. Name the gate.1 mark
    Answer
    1. XOR (EOR).

    Trap: OR also outputs 1 for 1 and 1.

  6. A lamp L is on when the switch S is 1 and the sensor T is 0. Write the logic expression for L.2 marks
    Answer
    1. T must be 0, so NOT T.
    2. L = S AND NOT T.

    Trap: NOT (S AND T) puts the NOT on the wrong part.

  7. Complete the truth table for the logic expression X = (A OR B) AND NOT C. | A | B | C | X | | --- | --- | --- | --- | | 0 | 0 | 0 | | | 0 | 0 | 1 | | | 0 | 1 | 0 | | | 0 | 1 | 1 | | | 1 | 0 | 0 | | | 1 | 0 | 1 | | | 1 | 1 | 0 | | | 1 | 1 | 1 | |4 marks
    Answer
    1. A OR B: 0, 0, 1, 1, 1, 1, 1, 1.
    2. NOT C: 1, 0, 1, 0, 1, 0, 1, 0.
    3. AND the columns: X = 0, 0, 1, 0, 1, 0, 1, 0.

    Trap: Applying NOT to the whole result gives 1, 1, 0, 1, 0, 1, 0, 1: the exact opposite.

  8. A safe unlocks (X = 1) only when its two keys P and Q are in the same position. The truth table gives X for each pair of inputs. Write the logic expression for X. Check it for P = 1 and Q = 0. | P | Q | X | | --- | --- | --- | | 0 | 0 | 1 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 1 |4 marks
    Answer
    1. Rows with X = 1: P = 0, Q = 0 and P = 1, Q = 1.
    2. Row terms: NOT P AND NOT Q, and P AND Q.
    3. X = (NOT P AND NOT Q) OR (P AND Q).
    4. Check P = 1, Q = 0: both terms are 0, so X = 0, as the table says.

    Trap: P XOR Q is the exact opposite: it is 1 only when the keys are in different positions.

  9. A student is asked to give the gates for Z = (A OR NOT B) NAND (B XOR C) without simplifying. The student writes: ``` G1 ← A OR B G2 ← NOT G1 G3 ← B XOR C Z ← G2 NAND G3 ``` (a) State the student's error. [1] (b) Give the correct gates in order. Each gate has a maximum of two inputs. [4] (c) Work out the number of rows of the truth table in which the student's circuit gives the wrong output. [3]8 marks
    Answer
    1. (a)
    2. The student used NOT (A OR B). The NOT belongs on B only, before the OR.
    3. (b)
    4. ``` G1 ← NOT B G2 ← A OR G1 G3 ← B XOR C Z ← G2 NAND G3 ```
    5. (c)
    6. B XOR C by row, 000 to 111: 0, 1, 1, 0, 0, 1, 1, 0.
    7. A OR NOT B: 1, 1, 0, 0, 1, 1, 1, 1, so the correct Z = 1, 0, 1, 1, 1, 0, 0, 1.
    8. NOT (A OR B): 1, 1, 0, 0, 0, 0, 0, 0, so the student's Z = 1, 0, 1, 1, 1, 1, 1, 1.
    9. The outputs differ in two rows: 101 and 110.

    Trap: A OR NOT B and NOT (A OR B) are different circuits: moving the NOT changes two outputs here.

  10. A cold store alarm X sounds (X = 1) when the door sensor D is 1 and the temperature sensor T is not 1, or when exactly one of the temperature sensor T and the power sensor P is 1. (a) Write the logic expression for X. [3] (b) Complete the truth table for X. [4] (c) An engineer replaces the last gate of the circuit with a NOR gate. Give the new output column and the number of rows in which the alarm now sounds. [2] | D | T | P | X | | --- | --- | --- | --- | | 0 | 0 | 0 | | | 0 | 0 | 1 | | | 0 | 1 | 0 | | | 0 | 1 | 1 | | | 1 | 0 | 0 | | | 1 | 0 | 1 | | | 1 | 1 | 0 | | | 1 | 1 | 1 | |9 marks
    Answer
    1. (a)
    2. D AND NOT T.
    3. Exactly one of T and P is 1: T XOR P.
    4. X = (D AND NOT T) OR (T XOR P).
    5. (b)
    6. D AND NOT T by row: 0, 0, 0, 0, 1, 1, 0, 0.
    7. T XOR P by row: 0, 1, 1, 0, 0, 1, 1, 0.
    8. OR the columns: X = 0, 1, 1, 0, 1, 1, 1, 0.
    9. (c)
    10. NOR is OR followed by NOT, so every output is reversed: 1, 0, 0, 1, 0, 0, 0, 1.
    11. The alarm now sounds in three rows.

    Trap: T OR P is also 1 when both are 1, which wrongly gives X = 1 in rows 011 and 111.

Say this, not that

Wording that loses the mark, against the wording the mark scheme credits.

Loses the markGets the mark
a circle, a box or words in place of a gatethe standard symbol for each gate
NOT (B OR C) for B OR NOT CB OR NOT C: the NOT is on C only
a NOR gate where XOR is neededXOR: output 1 when the inputs are different
a circuit simplified before drawinga circuit built gate by gate from the expression

Frequently asked questions

What is the output of an AND gate and an OR gate?
An AND gate outputs 1 only when both inputs are 1. An OR gate outputs 1 when at least one input is 1. A NOT gate has one input and gives the opposite value.
How do NAND, NOR and XOR gates work?
A NAND gate is an AND gate followed by NOT, so its output is 0 only when both inputs are 1. A NOR gate is an OR gate followed by NOT, so its output is 1 only when both inputs are 0. An XOR gate outputs 1 only when its two inputs are different.
How do you draw a logic circuit from a logic expression?
Build the circuit gate by gate from the expression, working out the brackets first. Do not simplify the expression. The mark scheme gives one mark for each correct gate with its correct inputs, and a NOT is a gate of its own.
How do you complete a truth table for a logic expression with three inputs?
A three-input truth table has eight rows, from 000 to 111. Use a working column for each gate, then combine the columns. Check the last column against the original expression, not against your own circuit.
How do you write a logic expression from a truth table?
Take each row whose output is 1. Write the AND of the inputs for that row, with NOT on any input that is 0. Join the rows with OR, then check the expression by working out its truth table again.
Is NOT (B OR C) the same as B OR NOT C?
No. In B OR NOT C the NOT is on C only. A common error was mixing up B OR NOT C and drawing NOT (B OR C) instead. Moving the NOT changes the outputs, so the answer is wrong.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters