Skip to content
Cambridge AS & A Level9618

Logic Gates and Logic Circuits

Computer Science 9618 Chapter Notes

Last updated November 2026

ShareWhatsAppPost

Logic Gates and Logic Circuits notes as a printable PDF.

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

Read the notes

The full Logic Gates and Logic Circuits notes as text: skim, search, and jump between subtopics.

~16 min read

1. Symbols, NOT, AND and OR

Every gate has its own standard symbol. Use the symbols shown in section 3.2 of the syllabus, and draw the circle on a NOT gate.

A NOT gate has one input and gives the opposite value. Every other gate has two inputs only.

An AND gate gives 1 only when both inputs are 1. An OR gate gives 0 when both inputs are 0, otherwise 1.

X = NOT A

X = A AND B

X = A OR B

Examiner insight

“Some candidates needed to be careful that they differentiate between AND and OR gates and between NOT and NOR gates. The best way to avoid any confusion was to use the symbols shown in section 3.2 of the syllabus.” “Candidates should also be aware of the need for care when drawing the shapes of the logic gates, it was sometimes very difficult to differentiate between an OR gate and an AND gate, and NOT gates were often shown without the circles.”

Worked example 13 marks

Tick one box in each row to identify the logic gate that each statement describes.

StatementANDNANDNORXOROR
The output is 1 only when both inputs are 1
The output is 1 only when both inputs are different
The output is 1 only when both inputs are 0
  1. 1

    both inputs are 1: AND [1]

  2. 2

    both inputs are different: XOR [1]

  3. 3

    both inputs are 0: NOR [1]

2. NAND, NOR and XOR gates

A NAND gate gives 0 when both inputs are 1, otherwise 1. A NOR gate gives 1 when both inputs are 0, otherwise 0.

An XOR gate gives 1 when one input is 1 and the other is 0, otherwise 0. Put another way, the output is 1 only if the two inputs are different.

A description must cover every combination of inputs. "The opposite of AND" is not enough.

X = A NAND B = NOT (A AND B)

X = A NOR B

X = A XOR B

Examiner insight

“Vague statements such as “a NAND gate is the opposite of an AND gate” were not enough. The answer needed to include a description of the operation of the gate for each possible combination of inputs.” “Some candidates need to improve their understanding of the difference between the symbols for an XOR gate and a NOR gate.”

Worked example 14 marks

Describe the operation of each of the following logic gates: NAND, NOR, XOR, OR.

  1. 1

    NAND: the output is 0 when both inputs are 1, otherwise the output is 1 [1]

  2. 2

    NOR: the output is 1 when both inputs are 0, otherwise the output is 0 [1]

  3. 3

    XOR: the output is 1 when one of the inputs is 1 and the other input is 0, otherwise the output is 0 [1]

  4. 4

    OR: the output is 0 when both inputs are 0, otherwise the output is 1 [1]

3. Truth tables for the gates

A truth table lists every combination of inputs and the output for each. Two inputs give four rows, in binary order: 00, 01, 10, 11.

```

A B | AND OR NAND NOR XOR 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 ```

NOT has one input: 0 gives 1 and 1 gives 0.

Examiner insight

“Some candidates needed to improve their understanding of the operation of the XOR gate. The most frequent incorrect answer was the complete opposite of what was expected.” “The most frequent incorrect answer was where the output was completely reversed because candidates had applied the XOR gate incorrectly.”

Worked example 12 marks

Create and complete the truth table for a two-input NAND gate.

  1. 1

    a truth table with correct inputs: 00, 01, 10, 11 [1]

  2. 2

    the NAND column: 1, 1, 1, 0 [1]

4. A truth table from an expression

Three inputs give eight rows, 000 to 111. Add a column in the working space for every bracket and every gate, and work from the innermost bracket outwards.

The mark scheme gives one mark for the first 4 rows and one for the second 4 rows, so one slip costs half the marks. Do the final NOT last: invert the whole column.

If you change a digit, cross the old one out completely and write the new one beside it.

Examiner insight

“A common incorrect answer was the opposite of the correct solution where candidates had correctly worked out the values for the bracketed expression, then omitted to invert the values for the final NOT.” “If binary digits need to be changed the original value should be crossed out completely and the new digit written alongside.”

Worked example 12 marks

Complete the truth table for the logic expression:

X = NOT ((NOT A AND NOT B) OR (NOT B AND NOT C))

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

    NOT A AND NOT B, rows 1 to 8: 1, 1, 0, 0, 0, 0, 0, 0

  2. 2

    NOT B AND NOT C, rows 1 to 8: 1, 0, 0, 0, 1, 0, 0, 0

  3. 3

    OR of the two: 1, 1, 0, 0, 1, 0, 0, 0. Final NOT inverts it.

  4. 4

    first four rows of X: 0, 0, 1, 1 [1]

  5. 5

    second four rows of X: 0, 1, 1, 1 [1]

5. A logic circuit from an expression

Read the expression from the innermost brackets outwards. Draw one gate for each operator and feed its output into the next gate.

Count the gates before you draw. Every NOT in the expression is its own NOT gate. The mark scheme gives marks for each part of the expression, then for the final gate.

Do not swap a gate for a different one that looks shorter. NOT A OR B is a NOT gate and an OR gate, not a NOR gate.

Examiner insight

“A common incorrect circuit was where the NOT A OR B had been incorrectly replaced with A NOR B.” “There were several logic circuits without the final NOT gate.”

Worked example 12 marks

Draw a logic circuit for the logic expression:

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

  1. 1

    the two bracketed parts: A NAND B and NOT A OR NOT C (a NAND gate on A and B; a NOT gate on each of A and C feeding an OR gate) [1]

  2. 2

    an XOR gate taking both bracketed outputs, then a NOT gate on its output to give X [1]

6. From a problem statement

A problem statement gives conditions in words. Turn each condition into a gate and join them. "And" becomes AND and "or" becomes OR.

Read the table of binary values first. It says what 1 means for each input. If 1 means rain is detected, then "rain is not detected" is NOT R.

In the security-system question the mark scheme writes the conditions straight into expressions, such as X = E AND A AND C.

X = E AND A AND C

Examiner insight

“There were several logic circuits with missing NOT gates and some candidates incorrectly replaced (NOT R) OR (NOT M) with a single NOR gate.”

Worked example 13 marks

A greenhouse has an automatic window. The window (X) operates according to the following criteria.

The window opens (X = 1) if: the temperature is too high and the wind speed is acceptable, and rain is not detected, or the manual override is off.

Draw a logic circuit to represent the operation of the window.

ParameterDescription of parameterBinary valueCondition
TTemperature1Too high
0Acceptable
WWind speed1Too high
0Acceptable
RRain1Detected
0Not detected
MManual override1On
0Off
  1. 1

    T AND NOT W [1]

  2. 2

    NOT R OR NOT M [1]

  3. 3

    a final AND joining the two parts: X = (T AND NOT W) AND (NOT R OR NOT M) [1]

7. An expression from a truth table

Find each row where the output is 1. Write one AND term for it, with NOT on every input that is 0 in that row. Join the terms with OR.

Check whether a short answer fits first. If the output is just NOT B, write that.

Other correct forms are accepted. One mark scheme accepted NOT (A XOR B) for a table that has output 1 when A and B are equal.

Examiner insight

“There were many unnecessarily complicated incorrect expressions given as the answer.”

Worked example 12 marks

Write the logic expression for the following truth table.

RSTQ
0000
0011
0100
0110
1000
1010
1101
1110
  1. 1

    output is 1 in two rows: 001 and 110

  2. 2

    one correct term: R AND S AND NOT T (row 110) [1]

  3. 3

    second correct term NOT R AND NOT S AND T, with the OR in the correct place [1]

  4. 4

    Q = (R AND S AND NOT T) OR (NOT R AND NOT S AND T)

8. An expression from a circuit

Work from the inputs to the output. Write the expression for each gate, put it in brackets, and use it as an input to the next gate.

The mark scheme credits each part and the joining gate, and the remainder must be bracketed with nothing extra. To fill in a truth table for a circuit, give each gate's output its own working column.

X = (A AND B) XOR (NOT C AND B)

Worked example 13 marks

A logic circuit has inputs A, B and C and output X. A NOR gate takes A and B. A NOT gate takes C. An XOR gate takes the output of the NOR gate and the output of the NOT gate, and gives X. Write the logic expression for X.

  1. 1

    the NOR gate: (A NOR B) [1]

  2. 2

    the NOT gate: NOT C [1]

  3. 3

    the XOR gate joins them, each bracketed: X = (A NOR B) XOR (NOT C) [1]

Recap

  • Every gate except NOT has two inputs only. Use the standard symbols, with the circle on NOT.
  • AND: 1 only when both inputs are 1. OR: 0 when both inputs are 0, otherwise 1.
  • NAND: 0 when both inputs are 1. NOR: 1 when both inputs are 0.
  • XOR: 1 only if the inputs are different.
  • A description covers every combination of inputs. "The opposite of AND" earns nothing.
  • Truth table from an expression: use working columns, bracket by bracket, and invert last for a final NOT.
  • Circuit from an expression: one gate per operator, and every NOT is a NOT gate.
  • Expression from a table: one AND term for each row with output 1, joined by OR.

End-of-chapter exercise

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

  1. State the output of an XOR gate when both inputs are 1.1 mark
    Answer
    1. XOR gives 1 only if the inputs are different. Both inputs are 1, so the output is 0.

    Trap: An OR gate gives 1 for these inputs, an XOR gate does not.

  2. State the number of inputs of each of these gates: NOT, NOR, XOR.3 marks
    Answer
    1. NOT has 1 input. NOR and XOR have 2 inputs each.

    Trap: Confusing NOT and NOR, which examiners reported: NOT is the only gate with one input.

  3. A two-input gate gives output 1, 1, 1, 0 for the input pairs 00, 01, 10, 11, in that order. Name the gate.2 marks
    Answer
    1. OR gives 0, 1, 1, 1 and XOR gives 0, 1, 1, 0, so neither matches. The gate is NAND.

    Trap: Reading only the rows 01 and 10 fits OR, XOR and NAND. Check the 00 row.

  4. Complete the truth table for X = A AND NOT B. Give X for the input pairs AB = 00, 01, 10, 11.2 marks
    Answer
    1. NOT B for the four rows: 1, 0, 1, 0, so A AND NOT B: 0, 0, 1, 0.

    Trap: The NOT applies to B only. NOT (A AND B) would give 1, 1, 1, 0.

  5. Complete the truth table for X = NOT (A OR B) XOR C. Give X for the input rows ABC = 000, 001, 010, 011, 100, 101, 110, 111, in that order.2 marks
    Answer
    1. A OR B: 0, 0, 1, 1, 1, 1, 1, 1, so NOT (A OR B): 1, 1, 0, 0, 0, 0, 0, 0.
    2. C: 0, 1, 0, 1, 0, 1, 0, 1, so the XOR column: 1, 0, 0, 1, 0, 1, 0, 1.

    Trap: Stopping after the OR column and forgetting to invert for the NOT.

  6. Describe the logic circuit for X = (A NAND B) OR NOT C. Name each gate and its inputs.3 marks
    Answer
    1. A NAND gate with inputs A and B, and a NOT gate with input C. An OR gate takes both outputs and gives X.

    Trap: NOT C is its own NOT gate. It is not part of the NAND gate.

  7. A machine runs (R = 1) only when the guard is closed and the start button is pressed. The guard sensor G gives 1 when the guard is open. The start button S gives 1 when pressed. Write a logic expression for R.2 marks
    Answer
    1. Guard closed means G = 0, so the condition is NOT G: R = NOT G AND S.

    Trap: Writing G AND S reads "closed" as 1. Check what 1 means for the sensor.

  8. A truth table has inputs A and B. The output X is 1 for the input pairs AB = 00 and 11, and 0 for 01 and 10. Write a logic expression for X.2 marks
    Answer
    1. Row 00 gives the term NOT A AND NOT B. Row 11 gives A AND B.
    2. X = (NOT A AND NOT B) OR (A AND B), or X = NOT (A XOR B).

    Trap: Writing terms for the rows where X is 0 gives the opposite function.

  9. The logic expression X = NOT ((NOT A OR B) XOR (B NOR C)) is given. (a) Give X for the input rows ABC = 000, 001, 010, 011, 100, 101, 110, 111, in that order. (b) A student drew NOT A OR B as a single NOR gate on A and B. Give the input rows where the student’s circuit gives a different X, and explain why.4 marks
    Answer
    1. (a)
    2. NOT A OR B: 1, 1, 1, 1, 0, 0, 1, 1. B NOR C: 1, 0, 0, 0, 1, 0, 0, 0.
    3. XOR: 0, 1, 1, 1, 1, 0, 1, 1. Final NOT: X = 1, 0, 0, 0 [1]; 0, 1, 0, 0 [1].
    4. (b)
    5. A NOR B: 1, 1, 0, 0, 0, 0, 0, 0, so the student’s X is 1, 0, 1, 1, 0, 1, 1, 1. X differs in rows 010, 011, 110 and 111 [1]: where B = 1, NOT A OR B gives 1 but A NOR B gives 0 [1].

    Trap: NOT A OR B replaced by A NOR B, the mistake examiners reported: NOR inverts the whole of A OR B, but here the NOT applies to A only.

  10. A car alarm sounds (S = 1) if the car is locked and either the door is not closed or the boot is not closed. (a) Write the logic expression for S. (b) Give S for the input rows LDB = 000, 001, 010, 011, 100, 101, 110, 111, in that order. (c) A student drew “the door is not closed or the boot is not closed” as a single NOR gate on D and B. Give the input rows where the student’s alarm stays silent but should sound. | Parameter | Description of parameter | Binary value | Condition | | --- | --- | --- | --- | | L | Lock | 1 | Locked | | | | 0 | Unlocked | | D | Door sensor | 1 | Closed | | | | 0 | Open | | B | Boot sensor | 1 | Closed | | | | 0 | Open |6 marks
    Answer
    1. (a)
    2. Door not closed is D = 0, so NOT D; boot not closed is B = 0, so NOT B: NOT D OR NOT B [1].
    3. S = L AND (NOT D OR NOT B) [1].
    4. (b)
    5. S = 0, 0, 0, 0 [1]; 1, 1, 1, 0 [1]. S needs L = 1, and D and B not both 1.
    6. (c)
    7. D NOR B makes the student’s S 0, 0, 0, 0, 1, 0, 0, 0. It stays silent in row 101 (door open, boot closed) [1] and row 110 (door closed, boot open) [1].

    Trap: Replacing NOT D OR NOT B with a single NOR gate, the mistake examiners reported: the alarm then sounds only when both are open. Check what 1 means for each sensor first.

Say this, not that

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

Loses the markGets the mark
“a NAND gate is the opposite of an AND gate”NAND gives 0 when both inputs are 1, otherwise 1
(NOT R) OR (NOT M) drawn as a single NOR gateNOT R OR NOT M: a NOT gate on each input, then an OR gate
(NOT A) AND (NOT B) drawn as a single NAND gatetwo NOT gates feeding an AND gate // A NOR B
a bracket worked out, with the final NOT missedthe bracket's values inverted for the final NOT

Frequently asked questions

What is the difference between an AND gate and an OR gate?
An AND gate gives 1 only when both inputs are 1. An OR gate gives 0 when both inputs are 0, otherwise it gives 1. A NOT gate has one input and gives the opposite value. Every other gate has two inputs only.
How do NAND, NOR and XOR gates work?
A NAND gate gives 0 when both inputs are 1, otherwise 1. A NOR gate gives 1 when both inputs are 0, otherwise 0. An XOR gate gives 1 only if the two inputs are different. A description must cover every combination of inputs, because "the opposite of AND" is not enough.
How do you complete a truth table for a logic expression?
Add a column in the working space for every bracket and every gate, and work from the innermost bracket outwards. Three inputs give eight rows, from 000 to 111. Invert the whole column last if the final operator is a NOT, and cross out any changed digit completely and write the new one beside it.
How do you draw a logic circuit from a logic expression?
Read the expression from the innermost brackets outwards. Draw one gate for each operator and feed its output into the next gate. Every NOT in the expression is its own NOT gate, so NOT A OR B is a NOT gate and an OR gate, not a NOR gate.
How do you write a logic expression from a truth table?
Find each row where the output is 1. Write one AND term for it, with NOT on every input that is 0 in that row. Join the terms with OR. Check first whether a short answer fits, because if the output is just NOT B, write that.
Can (NOT R) OR (NOT M) be drawn as a single NOR gate?
No. NOT R OR NOT M needs a NOT gate on each input, then an OR gate. Drawing it as a single NOR gate is a common error, and examiners reported that some answers replaced it this way. A vague statement such as "a NAND gate is the opposite of an AND gate" was also not enough.

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