Exercises — XOR, NAND, NOR, XNOR gates
Notation reminder (everything you need, in plain words):
Level 1 — Recognition
L1-Q1
For each gate, state the single input combination (for 2 inputs ) that makes its output the "odd one out": (a) NAND outputs ; (b) NOR outputs ; (c) XOR outputs for two equal inputs — name both such rows.
Recall Solution L1-Q1
(a) NAND is only when , i.e. . Every other row gives . (b) NOR is only when , i.e. . (c) XOR is when inputs are equal: the rows and .
L1-Q2
Fill the output column of this XNOR truth table (output when inputs are the same):
| A | B | |
|---|---|---|
| 0 | 0 | ? |
| 0 | 1 | ? |
| 1 | 0 | ? |
| 1 | 1 | ? |
Recall Solution L1-Q2
XNOR fires when both bits match:
| A | B | |
|---|---|---|
| 0 | 0 | 1 (match) |
| 0 | 1 | 0 (differ) |
| 1 | 0 | 0 (differ) |
| 1 | 1 | 1 (match) |
Level 2 — Application
L2-Q1
Evaluate directly: (a) (b) (c) (d) .
Recall Solution L2-Q1
(a) , then (NAND of two 1s — the only 0 case). (b) , then (NOR of two 0s — the only 1 case). (c) equal inputs → XOR . (d) equal inputs → XNOR .
L2-Q2
Build a NOT gate and an OR gate using only NAND gates. Show the Boolean simplification for each.
Recall Solution L2-Q2 — refer to the wiring figure

NOT from one NAND: tie both inputs to . OR from three NANDs: invert each input with a NAND-as-NOT, then NAND the two inverses. The final becomes because De Morgan turns "NOT(AND of NOTs)" into "OR". See Universal Gates.
L2-Q3
Compute for all four input rows and confirm it equals XOR.
Recall Solution L2-Q3
| A | B | sum | ||
|---|---|---|---|---|
| 0 | 0 | 0 | ||
| 0 | 1 | 1 | ||
| 1 | 0 | 1 | ||
| 1 | 1 | 0 |
Output column = XOR. ✅ (This is the SOP form.)
Level 3 — Analysis
L3-Q1
On which input row(s) do OR and XOR disagree? Prove it by comparing their full columns.
Recall Solution L3-Q1
| A | B | agree? | ||
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | ✔ |
| 0 | 1 | 1 | 1 | ✔ |
| 1 | 0 | 1 | 1 | ✔ |
| 1 | 1 | 1 | 0 | ✘ |
They disagree on exactly one row: . OR = "at least one "; XOR = "an odd number of s". Two s is even, so XOR drops to .
L3-Q2
Show algebraically that — i.e. inverting XOR gives XNOR. Start from .
Recall Solution L3-Q2
Apply the bar and use De Morgan (from Boolean Algebra Laws) to split the OR into an AND: Now De Morgan each factor: Expand (, drop out): That is exactly the XNOR SOP: . ✅
L3-Q3
Chain XOR across the bits left to right. What does the final value tell you about the count of s?
Recall Solution L3-Q3
Fold left to right: Final value → an odd number of s. (There are three s — odd. ✔) This is the parity idea in Parity Bits & Error Detection.
Level 4 — Synthesis
L4-Q1
Build XOR using only 4 NAND gates. Give the expression, then verify with and .
Recall Solution L4-Q1 — trace the 4-NAND network

Case (expect , inputs equal):
- Left
- Right
- Out ✅
Case (expect , inputs differ):
- Left
- Right
- Out ✅
L4-Q2
A half adder adds two bits producing a sum bit and carry bit . Express and with the gates on this page, then compute the outputs for all four inputs.
Recall Solution L4-Q2
Adding one-bit numbers: → sum digit , carry . The sum is when inputs differ (XOR); the carry is only when both are (AND):
| A | B | as number | ||
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |
| 0 | 1 | 1 | 0 | |
| 1 | 0 | 1 | 0 | |
| 1 | 1 | 0 | 1 |
Level 5 — Mastery
L5-Q1
Prove that NOR is universal by building NOT, OR, and AND from NOR only. (NOR: .)
Recall Solution L5-Q1
NOT: tie both inputs together. OR: NOR then NOT (invert the NOR back). AND: invert each input first, then NOR. All three basics built → NOR is universal, just like NAND. See Universal Gates.
L5-Q2
Using a K-map intuition (or Boolean laws), simplify and identify the resulting gate.
Recall Solution L5-Q2
Group the first two terms (they share ): So . Apply the absorption-style law (since lets pass): This is except when — the truth table . It is the implication gate (), equivalently NOT-A OR B.
| A | B | |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
L5-Q3
Generalise the parity result: for bits, the XOR of all of them equals iff the number of s is odd. Prove the inductive step for one extra bit.
Recall Solution L5-Q3
Let = XOR of the first bits, and suppose exactly when the count of s so far is odd (base case: one bit, , trivially true). Add bit : .
- If : — count unchanged, parity unchanged. ✔
- If : — count increases by one, flipping odd↔even, and XOR-with-1 flips . ✔ In both cases tracks the parity of the new count, so the claim holds for all by induction. This is why a single chained-XOR line is a parity bit generator.
Recall Final self-check (cover the answers)
Odd-one-out row for NAND? ::: → output . XOR vs OR disagree where? ::: Only at : OR, XOR. Half adder sum and carry? ::: , . NOT from one NOR? ::: . Chained XOR of ? ::: (odd count of 1s).
Connections
- XOR, NAND, NOR, XNOR gates — parent topic
- Boolean Algebra Laws — De Morgan & absorption used throughout
- AND, OR, NOT gates — the basics we rebuild
- Sum of Products (SOP) — source of the XOR/XNOR expressions
- Half Adder and Full Adder — L4-Q2
- Parity Bits & Error Detection — L3-Q3, L5-Q3
- Karnaugh Maps — L5-Q2 simplification
- Universal Gates — L2-Q2, L5-Q1