Home / Modern Physics / Logic Gates

Logic Gates: AND, OR, NOT, NAND, NOR, XOR

JEECBSE
Gate: AND A: 0 B: 0 Output Y: 0

The physics

A logic gate is a circuit that takes one or more binary (0 or 1) inputs and produces a single binary output, according to a fixed rule — its truth table. These simple building blocks combine to construct every digital circuit in existence, from a basic calculator to a modern computer processor's billions of transistors.

AND: Y=1 only if ALL inputs are 1   OR: Y=1 if ANY input is 1
NOT: inverts a single input   NAND = NOT(AND)   NOR = NOT(OR)
XOR: Y=1 only if inputs DIFFER   XNOR: Y=1 only if inputs are the SAME

NAND and NOR are called "universal gates" for a genuinely important reason — either one, used repeatedly on its own, can be wired together to reconstruct every other gate in this list (including AND, OR, and NOT), which is precisely why real digital chips are often built almost entirely from just one of these two gate types, for manufacturing simplicity.

Exam tip: a very common CBSE/JEE question asks you to identify a gate from its truth table alone, or asks how many distinct input combinations exist for a 2-input gate — since each input can independently be 0 or 1, there are always exactly 2\u00B2=4 possible input combinations for any 2-input gate.

Sample data: truth table of the six two-input gates

Each row gives the output (1 = high, 0 = low) of each gate for one combination of the inputs A and B.

ABANDORNANDNORXORXNOR
00001101
01011010
10011010
11110001

Conditions: ideal digital gates, 1 = high, 0 = low.

Notice: NAND is the opposite of AND in every row, and NOR the opposite of OR. XOR is 1 only when the inputs differ. Two inputs have 2² = 4 combinations, and three inputs would have 8. NAND alone can be used to build every other gate, which is why chips are often made from NAND gates.

🎯 Practice Zone

Puzzle 1. 🔀 NAND and NOR gates are specifically called "universal gates," meaning either one alone can be wired together (using multiple copies of just that one gate type) to reconstruct AND, OR, and NOT gates — genuinely surprising, since NAND and NOR seem like just two gates among many equally valid options. Why are these two specifically singled out as "universal," rather than, say, AND and OR?

NAND and NOR are each, individually, functionally complete — meaning every possible logical function (any conceivable truth table) can be built using only that single gate type, repeated as many times as needed. AND and OR gates, by contrast, genuinely CANNOT reconstruct a NOT gate on their own, no matter how many copies you use or how you wire them together — you fundamentally need some form of inversion capability somewhere in your toolkit, and NAND/NOR each conveniently bundle that inversion together with their basic AND/OR logic in a single gate, which is precisely why they alone qualify as "universal" while plain AND and OR do not.

Puzzle 2. 🔄 An XOR gate outputs 1 only when its two inputs genuinely DIFFER, and outputs 0 when they're the same — a distinctly different pattern from AND, OR, NAND, and NOR, which all have exactly ONE input combination (or three) producing their "special" output value. Why does XOR's truth table have a more balanced, symmetric 2-and-2 split rather than the lopsided 1-and-3 or 3-and-1 split the other basic gates show?

XOR is fundamentally answering a genuinely different kind of question than AND/OR/NAND/NOR — it's asking "do these two inputs disagree with each other?" rather than "are enough inputs individually true (or false)?" Since exactly half of all 2-input combinations (specifically 01 and 10) involve the inputs disagreeing, and the other half (00 and 11) involve them agreeing, XOR's truth table naturally splits evenly 2-and-2, reflecting this comparison-based logic rather than the simple threshold-counting logic that AND/OR/NAND/NOR are built around. This is exactly why XOR is specifically useful for binary addition circuits (checking whether two bits genuinely differ is precisely what's needed to compute a sum bit) in ways plain AND or OR simply cannot replicate.

Puzzle 3. 🚪 A simple "AND" security system requiring BOTH a correct key AND a correct passcode before unlocking is intuitively safer than requiring just one or the other. Why does combining two independent conditions with AND logic (rather than OR logic) genuinely improve security here, and would this reasoning still hold if you needed three independent conditions instead of two?

AND logic requires ALL conditions to be simultaneously satisfied for the output to be 1 — an intruder would need to defeat every single security layer (both the physical key AND the correct passcode) to succeed, genuinely multiplying the difficulty rather than just adding it, since failing even one single condition blocks the entire system. OR logic, by contrast, would make the system LESS secure (any single condition being met alone would unlock it, meaning defeating just the weakest single layer succeeds) — exactly the opposite of what a security system needs. This reasoning scales directly to three or more conditions too: a 3-input AND gate would require defeating all three layers simultaneously, making the system even harder to compromise than the 2-input case, precisely the same underlying logic just extended further.

Puzzle 4. 💡 A basic incandescent light bulb circuit controlled by two separate switches (like a staircase light controllable from both the top and bottom floor) is a classic real-world application of XOR logic, not simple AND or OR logic. Why does this common household wiring specifically need XOR's "differ" logic rather than the simpler AND/OR gates?

For a staircase light to be toggleable from EITHER switch independently (flip either one, regardless of the other switch's current position, and the light should change state), the actual required logic is precisely XOR — light ON exactly when the two switches are in DIFFERING positions, light OFF when they match. If this circuit instead used simple AND logic, both switches would need to be simultaneously flipped to affect the light (impossible to use the light from just one location conveniently); with OR logic, the light would get stuck ON permanently once EITHER switch was flipped, with no way to turn it back off from that same switch alone. XOR's specific "differ" logic is precisely what allows either switch, used alone, to reliably toggle the light's state.

Puzzle 5. ⚙️ A modern computer processor performs staggeringly complex tasks (video decoding, running games, artificial intelligence) using nothing but combinations of these same basic logic gates, wired together by the billions. How can something as fundamentally simple as AND, OR, and NOT gates possibly combine to produce such sophisticated computational behavior?

This is genuinely one of computer science's most beautiful, foundational insights: any conceivable logical function, no matter how complex, can be constructed by combining enough basic gates in the right pattern — arithmetic (adders built from XOR and AND gates), memory (flip-flops built from cross-coupled NAND or NOR gates), and even decision-making circuits are all ultimately built from nothing more exotic than these same handful of basic gate types, just combined at truly enormous scale (modern processors contain many billions of individual transistors implementing these gates). Complexity here doesn't come from the individual building blocks being sophisticated — it comes entirely from the sheer SCALE and clever ORGANIZATION of combining astronomically many simple, well-understood pieces together.

Problem 1 (NEET/CBSE level). 📘 For an AND gate with A=1, B=0, find the output Y.

AND requires BOTH inputs to be 1 for Y=1
Since B=0, Y = 0

Problem 2 (JEE Main level). 📗 For a NAND gate with the same inputs (A=1, B=0), find Y, and verify it's the exact opposite of the AND gate's result.

NAND = NOT(AND); AND gave Y=0 in Problem 1
NAND output = NOT(0) = 1 — confirmed opposite of AND, exactly as the name "NOT-AND" implies

Problem 3 (WBJEE level). 📙 For an XOR gate, find Y for all four possible input combinations (A,B) = (0,0), (0,1), (1,0), (1,1).

(0,0)\u2192Y=0 (same, so XOR=0)
(0,1)\u2192Y=1 (differ)  (1,0)\u2192Y=1 (differ)
(1,1)\u2192Y=0 (same, so XOR=0)

Problem 4 (CBSE Class 12 level). 📕 A circuit combines A and B first through an AND gate, then feeds that AND gate's output through a NOT gate to produce final output Y. Find Y for A=1, B=1, and identify which single gate type this two-gate combination is equivalent to.

AND(1,1) = 1; NOT(1) = 0
This exact combination (AND followed by NOT) is, by definition, equivalent to a single NAND gate — precisely demonstrating how NAND is literally "NOT-AND" built from two simpler gates

Problem 5 (JEE Advanced style). 📓 Using only NAND gates (as discussed in Puzzle 1's "universal gate" property), a NOT gate can be built by feeding the SAME single input into both of a NAND gate's two inputs simultaneously (i.e., A=B). Verify this produces correct NOT-gate behavior for both A=0 and A=1.

NAND(0,0) = NOT(AND(0,0)) = NOT(0) = 1 = NOT(0) \u2714
NAND(1,1) = NOT(AND(1,1)) = NOT(1) = 0 = NOT(1) \u2714
Both cases match standard NOT gate behavior exactly \u2014 confirming a NAND gate with tied inputs genuinely functions as a NOT gate, exactly as the universal-gate property from Puzzle 1 promises
📐
1854

George Boole publishes "An Investigation of the Laws of Thought," establishing Boolean algebra — the mathematical framework of true/false logic that would, nearly a century later, become the theoretical foundation of all digital circuit design.

🔬
1937

Claude Shannon, in his landmark master's thesis, demonstrates that Boolean algebra can directly describe and design electrical switching circuits — connecting Boole's abstract 19th-century logic to genuinely practical electrical engineering for the first time.

💻
1940s\u20131950s

Early electronic computers are built using physical logic gates constructed from vacuum tubes, later transitioning to transistors — directly implementing the AND, OR, NOT, NAND and NOR gates explored in this simulation as genuine physical circuits.

🖥️
Present day

Every modern computer processor, smartphone, and digital device contains billions of these exact same basic logic gates, now manufactured as microscopic transistor circuits on silicon chips — Shannon's 1937 insight connecting Boolean logic to physical switches remains the foundational principle of essentially all modern computing.