Logic gates

Computer Science · Boolean logic. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science topics

The idea

A logic gate is a small electronic circuit that takes binary inputs and gives one binary output. Each input and output is either 1 (on, true) or 0 (off, false). Computers are built from very large numbers of these gates.

You need six gates: NOT, AND, OR, NAND, NOR and XOR. The NOT gate has one input. The others have two inputs at this level. For each gate you must know its symbol, what it does in words, and its output for every possible input.

NAND and NOR are simply AND and OR with the output inverted. In a symbol, a small circle at the output means the output is inverted.

Rules to remember

Common mistake

Students confuse OR with XOR. With both inputs at 1, OR gives 1 but XOR gives 0. For NAND and NOR, work out AND or OR first and then invert the result.

Worked example

Inputs A = 1 and B = 0 are connected to a NAND gate and, separately, to a NOR gate. What is the output of each gate?

  1. NAND: first find A AND B = 1 AND 0 = 0, then invert it to get 1.
  2. NOR: first find A OR B = 1 OR 0 = 1, then invert it to get 0.

Answer: NAND output = 1, NOR output = 0

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

← Structured query language (SQL)Logic circuits and logic expressions →Take a Computer Science test