A logic gate takes one or more inputs, each 0 or 1, and produces a single output of 0 or 1 by a fixed rule. Gates are the building blocks of every digital circuit, from a calculator to a processor. In computer awareness sections, questions usually ask for a gate's output for given inputs, the number of rows in a truth table, or which gates are universal.

A truth table lists every possible combination of inputs and the output for each. With n inputs there are 2ⁿ combinations, because each input independently takes one of two values.

So a three-input gate has 2³ = 8 rows, and a two-input gate has 4.

There are three basic gates. AND outputs 1 only if every input is 1. OR outputs 1 if at least one input is 1. NOT has a single input and flips it. The other four gates are built from these: NAND is NOT-AND, NOR is NOT-OR, XOR (exclusive OR) outputs 1 when the inputs differ, and XNOR outputs 1 when they are the same.

ABANDORNANDNORXORXNOR
00001101
01011010
10011010
11110001

NOT has only one input: NOT 0 = 1 and NOT 1 = 0.

A quick way to read the table: each NAND column is the AND column flipped, each NOR column is the OR column flipped, and XNOR is XOR flipped. If you remember AND, OR and XOR, you can derive the rest in seconds.

Worked example 1: AND

A = 1, B = 0. AND needs both to be 1, so the output is 0. A handy way to think of it: AND behaves like multiplication, 1 × 0 = 0.

Worked example 2: counting ones in the OR column

OR gives 0 only when both inputs are 0. So of the four rows, 3 give an output of 1.

Worked example 3: NAND

A = 1, B = 1. AND gives 1, and the NOT flips it, so NAND gives 0. This is the only row where NAND outputs 0.

Worked example 4: XOR

A = 1, B = 0. The inputs differ, so XOR gives 1. XOR behaves like adding the bits and keeping only the last binary digit.

Across its four rows, XOR outputs 1 exactly twice, in the two rows where the inputs differ.

Worked example 5: NOR

A = 0, B = 0. OR gives 0, and the NOT flips it, so NOR gives 1.

NAND and NOR are called universal gates because any circuit can be built from one of them alone. With NAND, for example:

  • NOT A = A NAND A, since joining both inputs gives NOT (A AND A) = NOT A.
  • A AND B = (A NAND B) NAND (A NAND B), which flips NAND back to AND.
  • A OR B = (NOT A) NAND (NOT B), using the NAND-built NOT from the first line.

The third line rests on De Morgan's laws: NOT (A AND B) equals (NOT A) OR (NOT B), and NOT (A OR B) equals (NOT A) AND (NOT B). In words, flipping a combined result flips each input and swaps AND with OR.

Worked example 6: checking De Morgan's law

A = 1, B = 0. Left side: A AND B = 0, so NOT gives 1. Right side: NOT A = 0 and NOT B = 1, and 0 OR 1 = 1. Both sides equal 1, so the difference is 0, as the law says.

Expressions such as (A AND B) OR (NOT C) are evaluated like arithmetic: work out the innermost brackets first, then combine. NOT applies only to what immediately follows it unless brackets say otherwise.

Worked example 7: a three-variable expression

A = 1, B = 0, C = 0. A AND B = 0. NOT C = 1. Then 0 OR 1 = 1.

Write each intermediate value on paper. With three or more gates, holding results in your head is where most mistakes happen.

  • ✘ Treating XOR like OR when both inputs are 1. OR gives 1; XOR gives 0.
  • ✘ Saying a truth table with n inputs has 2n rows instead of 2ⁿ.
  • ✘ Applying NOT to a whole expression when it covers only one variable.
  • ✘ Calling AND or OR universal. Only NAND and NOR are.

Gates work on the bits covered in binary, octal and hexadecimal conversion. For broader revision, see computer and IT fundamentals and the computer awareness cheat code.

Q1. A three-input AND gate receives the inputs 1, 1 and 0. What is its output? easy

✅ Answer: (a) 0

💡 Explanation: An AND gate outputs 1 only when every input is 1. One input is 0, so the output is 0. The order of the inputs never matters for AND.

Q2. Which gates are called universal gates? easy

✅ Answer: (b) NAND and NOR

💡 Explanation: Any logic circuit can be built using only NAND gates, or using only NOR gates. That is why these two are called universal. AND, OR and XOR cannot produce NOT on their own.

Q3. How many rows does the complete truth table of a four-input gate have? easy

✅ Answer: (c) 16

💡 Explanation: Each input can be 0 or 1, so four inputs give 2 × 2 × 2 × 2 = 2⁴ = 16 combinations, one row each.

Q4. What is the output of a two-input XOR gate when both inputs are 1? easy

✅ Answer: (b) 0

💡 Explanation: XOR outputs 1 only when the inputs differ. Both inputs are 1, so they are the same and the output is 0. OR would give 1 here, which is the trap.

Q5. If A = 0, B = 1 and C = 1, what is the value of (A OR B) AND (NOT C)? medium

✅ Answer: (d) 0

💡 Explanation: A OR B = 0 OR 1 = 1. NOT C = NOT 1 = 0. Then 1 AND 0 = 0.

Q6. What is the output of a NOR gate when both inputs are 0? easy

✅ Answer: (c) 1

💡 Explanation: NOR is OR followed by NOT. 0 OR 0 = 0, and NOT 0 = 1. NOR gives 1 only in this one row.

What is the difference between XOR and OR?

They differ only when both inputs are 1. OR gives 1 if at least one input is 1, so it gives 1 for the inputs 1 and 1. XOR gives 1 only when exactly one input is 1, so it gives 0 when both are 1.

How do I remember which gate is which?

Learn three base gates: AND needs all ones, OR needs at least one, NOT flips. Every other gate is a variant: NAND and NOR are AND and OR followed by NOT, and XOR checks whether the inputs differ, with XNOR as its opposite.

All problems and solutions on this page are original. No outside facts are relied on; every numeric answer is recomputed by software before publishing.

How this page was prepared. Drafted with AI assistance (Claude (Anthropic AI model)) from the sources listed above. 14 calculations on this page were recomputed by software and matched. Automated checks also covered structure, internal links and duplicate text. Software checks cannot confirm facts. Reviewed by praveenkumar on 2026-10-24 against the sources listed above.

Found an error? Report it and we will correct the page.