Show Working
Open the app

GCSE Computer ScienceEvery exam board

Logic gates: AND, OR, NOT and truth tables

A logic gate takes inputs that are each 1 (TRUE) or 0 (FALSE) and gives one output. Learn what each gate does and you can work out any circuit, one gate at a time.

The rules Quiz yourself: 10 questions

Worked example: and, or and not

What is NOT A when A = 1?

  1. Put in the values: A = 1.
  2. NOT A = NOT 1 = 0 (NOT flips 1 to 0).
  3. So the output is 0 (FALSE).

Answer 0 (FALSE)

01 / The gatesTruth tables

The four gates and their truth tables

AND

The output is 1 only when both inputs are 1. Drawn as a D shape.

ABA AND B
000
010
100
111
Every board

OR

The output is 1 when at least one input is 1. Drawn with a curved back and a pointed front.

ABA OR B
000
011
101
111
Every board

NOT

One input, and it flips it: 1 becomes 0 and 0 becomes 1. Drawn as a triangle with a small circle at its tip.

ANOT A
01
10
Every board

XOR

Exclusive OR. The output is 1 when the two inputs are different. Drawn like OR with an extra curved line behind it.

ABA XOR B
000
011
101
110
AQA and Eduqas

02 / The rulesLearn these

How to answer logic questions

Rows in a truth table

With n inputs there are 2n rows: 4 rows for two inputs, 8 rows for three. Fill the inputs in by counting up in binary, 000 to 111, so you never miss one.

Brackets first

Work out anything in brackets first. NOT applies to the input or bracket straight after it, so NOT A AND B means (NOT A) AND B.

Circuits, left to right

Start at the inputs and work towards the output. Write the 0 or 1 coming out of each gate on the diagram as you go.

Circuit to expression

Name each gate from the inputs outwards. A and B into an AND gate, then into a NOT gate, is NOT (A AND B).

Add a column per gate

For a long expression, give the truth table an extra column for each part, such as A AND B, then combine the columns for the final output.

Worth knowing

Read the question for the words AND and OR in real situations. "The alarm sounds if the door is open and the system is on" is an AND gate. "The light comes on if either switch is pressed" is an OR gate.

03 / Quiz yourselfTry it, then tap to check

Logic gates questions to try

Work each one out on paper first, then open the answer and compare your working with ours. Every question here was made and checked by the Show Working app.

01 / AND, OR and NOTEvery board

What is NOT A when A = 1?

Show the answer and working
  1. Put in the values: A = 1.
  2. NOT A = NOT 1 = 0 (NOT flips 1 to 0).
  3. So the output is 0 (FALSE).

Answer 0 (FALSE)

02 / AND, OR and NOTEvery board

What is A OR B when A = 1 and B = 1?

Show the answer and working
  1. Put in the values: A = 1, B = 1.
  2. A OR B = 1 OR 1 = 1 (at least one is 1).
  3. So the output is 1 (TRUE).

Answer 1 (TRUE)

03 / Boolean expressionsEvery board

Q = (A AND B) OR NOT C
What is Q when A is TRUE, B is FALSE and C is FALSE?

Show the answer and working
  1. Put in the values: A = 1, B = 0, C = 0.
  2. A AND B = 1 AND 0 = 0 (they are not both 1).
  3. NOT C = NOT 0 = 1 (NOT flips 0 to 1).
  4. (A AND B) OR NOT C = 0 OR 1 = 1 (at least one is 1).
  5. So Q = 1 (TRUE).

Answer 1 (TRUE)

04 / Boolean expressionsEvery board

Q = NOT ((A AND B) OR C)
What is Q when A = 1, B = 1 and C = 0?

Show the answer and working
  1. Put in the values: A = 1, B = 1, C = 0.
  2. A AND B = 1 AND 1 = 1 (both are 1).
  3. (A AND B) OR C = 1 OR 0 = 1 (at least one is 1).
  4. NOT ((A AND B) OR C) = NOT 1 = 0 (NOT flips 1 to 0).
  5. So Q = 0 (FALSE).

Answer 0 (FALSE)

05 / Logic circuitsOCR, AQA, Eduqas

Look at the logic circuit.
What is the output Q when A = 1, B = 0 and C = 0?

ABCQ
Show the answer and working
  1. The circuit is Q = (NOT (A OR B)) AND NOT C.
  2. Put in the values: A = 1, B = 0, C = 0.
  3. A OR B = 1 OR 0 = 1 (at least one is 1).
  4. NOT (A OR B) = NOT 1 = 0 (NOT flips 1 to 0).
  5. NOT C = NOT 0 = 1 (NOT flips 0 to 1).
  6. (NOT (A OR B)) AND NOT C = 0 AND 1 = 0 (they are not both 1).
  7. So Q = 0 (FALSE).

Answer 0 (FALSE)

06 / Logic circuitsOCR, AQA, Eduqas

Look at the logic circuit.
What is the output Q when A = 0 and B = 0?

ABQ
Show the answer and working
  1. The circuit is Q = NOT A AND B.
  2. Put in the values: A = 0, B = 0.
  3. NOT A = NOT 0 = 1 (NOT flips 0 to 1).
  4. NOT A AND B = 1 AND 0 = 0 (they are not both 1).
  5. So Q = 0 (FALSE).

Answer 0 (FALSE)

07 / XOR in expressionsAQA, Eduqas

XOR (exclusive OR) gives 1 when its two inputs are different.
Q = (A OR B) XOR C
What is Q when A = 1, B = 1 and C = 0?

Show the answer and working
  1. Put in the values: A = 1, B = 1, C = 0.
  2. A OR B = 1 OR 1 = 1 (at least one is 1).
  3. (A OR B) XOR C = 1 XOR 0 = 1 (they are different).
  4. So Q = 1 (TRUE).

Answer 1 (TRUE)

08 / XOR in expressionsAQA, Eduqas

XOR (exclusive OR) gives 1 when its two inputs are different.
Q = (A OR B) XOR (B AND C)
What is Q when A = 1, B = 1 and C = 0?

Show the answer and working
  1. Put in the values: A = 1, B = 1, C = 0.
  2. A OR B = 1 OR 1 = 1 (at least one is 1).
  3. B AND C = 1 AND 0 = 0 (they are not both 1).
  4. (A OR B) XOR (B AND C) = 1 XOR 0 = 1 (they are different).
  5. So Q = 1 (TRUE).

Answer 1 (TRUE)

09 / Truth tables: count the 1sEvery board

Q = (A AND B) OR NOT C
Complete a truth table for Q with every possible set of inputs. In how many rows is Q equal to 1?

Show the answer and working
  1. With 3 inputs there are 2^3 = 8 rows.
  2. A = 0, B = 0, C = 0: Q = 1
  3. A = 0, B = 0, C = 1: Q = 0
  4. A = 0, B = 1, C = 0: Q = 1
  5. A = 0, B = 1, C = 1: Q = 0
  6. A = 1, B = 0, C = 0: Q = 1
  7. A = 1, B = 0, C = 1: Q = 0
  8. A = 1, B = 1, C = 0: Q = 1
  9. A = 1, B = 1, C = 1: Q = 1
  10. Q is 1 in 5 of the 8 rows.

Answer 5

10 / Truth tables: count the 1sEvery board

Q = NOT ((A AND B) OR C)
Complete a truth table for Q with every possible set of inputs. In how many rows is Q equal to 1?

Show the answer and working
  1. With 3 inputs there are 2^3 = 8 rows.
  2. A = 0, B = 0, C = 0: Q = 1
  3. A = 0, B = 0, C = 1: Q = 0
  4. A = 0, B = 1, C = 0: Q = 1
  5. A = 0, B = 1, C = 1: Q = 0
  6. A = 1, B = 0, C = 0: Q = 1
  7. A = 1, B = 0, C = 1: Q = 0
  8. A = 1, B = 1, C = 0: Q = 0
  9. A = 1, B = 1, C = 1: Q = 0
  10. Q is 1 in 3 of the 8 rows.

Answer 3

04 / By exam boardNot affiliated with any board

Logic gates on each exam board

OCR (J277)AND, OR and NOT gates, logic diagrams and truth tables, combining gates.
AQA (8525)NOT, AND, OR and XOR, circuits and truth tables with up to three inputs. AQA also writes expressions with a dot for AND, + for OR, ⊕ for XOR and a bar over the top for NOT.
Edexcel (1CP2)AND, OR and NOT in truth tables with up to three inputs, and in code.
EduqasAND, OR, NOT and XOR, plus the rules of Boolean algebra to simplify an expression.

Show Working is not affiliated with AQA, Edexcel (Pearson), OCR or WJEC Eduqas. Check your own board's specification for the exact wording.

05 / QuestionsGCSE Computer Science

Logic gates, answered

What are the three basic logic gates?

AND, OR and NOT. AND gives 1 only when both inputs are 1, OR gives 1 when at least one input is 1, and NOT flips its one input. AQA and Eduqas also teach XOR.

What is the difference between AND and OR?

AND needs both inputs to be 1 to give 1. OR needs only one of them. So inputs of 1 and 0 give 0 through an AND gate but 1 through an OR gate.

How many rows does a truth table have?

Two to the power of the number of inputs. Two inputs give 4 rows and three inputs give 8 rows. List the inputs by counting up in binary so none is missed.

What does XOR mean?

XOR is exclusive OR. It gives 1 when the two inputs are different and 0 when they are the same. It is on the AQA and Eduqas specifications.

Which way do you work through a logic circuit?

From the inputs on the left to the output on the right. Work out each gate in turn and write its output on the diagram before moving to the next gate.

06 / Practise itiPhone, iPad and the web

More logic gates questions in Show Working

The app makes fresh logic gates questions every time, so they never run out. Get one wrong and you see every step of the working.

The worked answer in Show Working: the answer, then numbered steps in plain words

Show WorkingFree on the App StoreFree in your browser, no download

Open it free