---
title: "Encoder; NAND and XOR truth tables"
subject: "Basic Electronics Engineering"
chapter: 6
key: "semester_2/basic_electronics_engineering:encoder-truth-tables"
source: https://www.bctengineer.com/q/semester_2/basic_electronics_engineering/encoder-truth-tables
site: BCT Engineering
---

# Encoder; NAND and XOR truth tables

Basic Electronics Engineering · Chapter 6: Digital Electronics

- Asked in: 2069 Bhadra, 2+2 marks
- Video: [Encoder in Digital Electronics | Working, Application and Logic Circuit of Encoder](https://www.youtube.com/watch?v=NWiPVMDh7GE) — ALL ABOUT ELECTRONICS
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_2/basic_electronics_engineering/encoder-truth-tables
- Whole chapter: https://www.bctengineer.com/md/semester_2/basic_electronics_engineering/chapter-6

## Question

Define encoder. Draw truth tables of NAND and XOR gates.

## Short answer

An encoder converts 2ⁿ input lines to an n-bit binary code, only one input active at a time. NAND gate output is (AB)' : 1,1,1,0 for inputs 00,01,10,11. XOR gate output is A⊕B: 0,1,1,0 for those inputs.

## Answer

#### Encoder

An **encoder** is a combinational circuit that converts up to 2ⁿ input lines into an n-bit binary code at the output. Only one input is active at a time, and the output is the binary code of that input. Examples: an 8-to-3 encoder, or a decimal-to-BCD encoder (10 inputs, 4 outputs). It does the opposite of a decoder.

| I3 | I2 | I1 | I0 | Y1 | Y0 |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 |

(4-to-2 encoder: Y1 = I3 + I2, Y0 = I3 + I1.)

#### Truth table of NAND gate (Y = (AB)')

| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |

#### Truth table of XOR gate (Y = A⊕B = A'B + AB')

| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What does an encoder do?
   A. Converts an n-bit binary code into 2^n separate output lines
   B. Converts 2^n input lines into an n-bit binary code
   C. Adds two binary numbers
   D. Stores one bit of data
   Answer: B. An encoder takes 2^n input lines (one active at a time) and gives the n-bit binary code of the active input. A decoder does the opposite. (Key point: Definition of encoder)

2. In the 4-to-2 encoder, only I2 = 1 (others 0). What are Y1 Y0?
   A. 00
   B. 01
   C. 11
   D. 10
   Answer: D. I2 is input number 2, so the output is binary 10 (Y1 = I3 + I2 = 1, Y0 = I3 + I1 = 0). (Key point: 4-to-2 encoder output)

3. For inputs A = 1, B = 1, what are the outputs of NAND and XOR gates?
   A. NAND = 1, XOR = 1
   B. NAND = 0, XOR = 1
   C. NAND = 0, XOR = 0
   D. NAND = 1, XOR = 0
   Answer: C. NAND = (AB)' = 0 when both inputs are 1, and XOR gives 0 when the inputs are equal. (Key point: NAND and XOR truth tables)

## Related in Basic Electronics Engineering

- [X-OR gate using NAND gates only](https://www.bctengineer.com/question.md?key=semester_2%2Fbasic_electronics_engineering%3Axor-using-nand) — Basic Electronics Engineering, chapter 6
- [Why NOR and NAND are universal gates](https://www.bctengineer.com/question.md?key=semester_2%2Fbasic_electronics_engineering%3Auniversal-gates-nor-nand) — Basic Electronics Engineering, chapter 6

## Related in other subjects

- [XOR gate using minimum NAND gates](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Axor-using-nand-only) — Digital Logic, chapter 2, asked 2×
- [3-input XOR using NAND gates only](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Athree-input-xor-nand) — Digital Logic, chapter 2, asked 2×
- [De Morgan's laws; XOR from NAND gates](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Ademorgan-importance-xor-nand) — Digital Logic, chapter 2
- [Prove De Morgan's theorems; XOR using NAND](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Ademorgan-prove-xor-nand) — Digital Logic, chapter 2, asked 3×
