Boolean Logic and Basic Logic Gates

Boolean Logic and Basic Logic Gates. Foundational Computer Awareness explanations, examples and explained practice questions for banking and recruitment exam preparation.

By Akhilesh Saini

What you will learn

  • What Boolean values 0/1 or False/True mean.
  • How AND, OR and NOT act on Boolean inputs.
  • The basic meaning of NAND, NOR, XOR and XNOR.
  • How to answer two-input truth-table questions.

Why this topic matters

A bank's software can check several conditions before performing an action. For example, the simplified rule “Proceed only if the account is active AND authorization succeeds” is a Boolean decision. Physical digital circuits also implement logical operations using electronic gates. In recruitment exams, the most frequent tasks are to identify the gate from its output rule and read simple truth tables.

Boolean logic: two truth values

Boolean logic works with statements that are either true or false. In introductory digital logic, we represent them as:

  • 1 = True (condition holds)
  • 0 = False (condition does not hold)

Digital hardware uses signals to represent these logic levels; the logical symbols describe meaning, not one universal voltage value. Unlike ordinary arithmetic, Boolean algebra has special operations: AND, OR and NOT.

AND: both conditions must be true

For inputs A and B, the AND output is 1 only when both inputs are 1.

A simple example is a secured operation that requires both an active session and a successful authorization check. If either requirement fails, access should not proceed under this simplified rule.

Notation: A AND B, A · B, or sometimes AB.

OR: at least one condition must be true

The OR gate outputs 1 when A or B or both are true. This is inclusive OR: a result of 1 is still valid when both inputs are 1.

Notation: A OR B or A + B in Boolean algebra. Here + is a logical symbol; it does not mean normal arithmetic addition.

NOT: reverse the input

NOT is a one-input gate (also called an inverter). It turns 0 into 1 and 1 into 0. It can be written as NOT A, ¬A or Ā (A with a bar).

For example, if A=1 means “account locked,” then NOT A=1 means “account not locked.” The usefulness of the result still depends on the definition of A.

Full two-input truth table

This table is worth practicing because it contains the most common gates in one place:

ABANDORNANDNORXORXNOR
00001101
01011010
10011010
11110001
Comparison of basic logic gates with their output rules: both, either, invert, not both, neither, different and equal.
Logic gates and outputs

NAND and NOR: inverses of AND and OR

NAND means NOT-AND. It reverses the AND result, so it outputs 0 only when both inputs are 1. Otherwise, its output is 1.

NOR means NOT-OR. It reverses the OR result, so it outputs 1 only when both inputs are 0. Otherwise, its output is 0.

These two gates are often called universal gates because either NAND gates alone or NOR gates alone can be combined to construct the standard Boolean operations. At awareness level, memorize the names and this fact; detailed circuit construction is unnecessary.

XOR and XNOR: different and equal

XOR stands for exclusive OR. With two inputs, its output is 1 when the inputs differ (0,1 or 1,0), and 0 when they are the same.

XNOR is the inverse of XOR. With two inputs, its output is 1 when the inputs are equal (0,0 or 1,1). It is often useful to think of the two-input XNOR gate as an “equality check.”

Remember: OR and XOR differ on the input A=1, B=1:

  • 1 OR 1 = 1
  • 1 XOR 1 = 0

This is one of the most common objective-exam traps.

Worked examples

Example 1 — AND gate: A=1, B=0. Since one requirement is false, A AND B = 0.

Example 2 — NOR gate: A=0, B=0. OR produces 0, so NOR reverses it to 1.

Example 3 — XOR gate: A=1, B=1. The inputs match, so XOR is 0 and XNOR is 1.

Example 4 — Combined expression: Evaluate (A AND B) OR (NOT C) for A=1, B=0, C=0:

  1. A AND B = 1 AND 0 = 0.
  2. NOT C = NOT 0 = 1.
  3. 0 OR 1 = 1.

The parentheses make the order explicit. Real computer programs use language-specific syntax, but the Boolean concept is the same.

Example 5 — Simplified banking condition: Let A=1 if the account is active, and B=1 if the user has passed an authorization check. A conceptual rule Proceed = A AND B outputs 0 whenever either requirement fails. This is only a teaching example, not a specification of any bank's actual security design.

One-input and two-input operations

For a single Boolean input, there are two possible combinations: 0 and 1. For two inputs, there are four (00, 01, 10, 11). For three inputs, there would be eight combinations. This follows 2ⁿ possible combinations for n independent Boolean inputs, but the lesson requires only small truth tables.

Important terms

TermMeaning
Boolean valueOne of two truth values, false or true
Logic gateCircuit or functional operation implementing a Boolean rule
Truth tableTable showing output for each possible input combination
InverterNOT gate; reverses the Boolean value
NAND/NORInverted AND / inverted OR
XORExclusive OR; for two inputs, true when they differ
XNORInverted XOR; for two inputs, true when they match
Universal gateGate type from which other common Boolean logic can be constructed

Common confusions and exam traps

  • Inclusive OR versus exclusive OR: OR outputs 1 when both inputs are 1; XOR does not.
  • NAND and NOR are not ordinary AND/OR: They reverse their respective outputs.
  • NOT needs only one input in its basic form; the other common gates here are shown with two.
  • Boolean plus is OR: 1 + 1 in Boolean OR notation is 1, not arithmetic 2.
  • Truth values are conventions: A high voltage is not guaranteed to mean logical 1 in every circuit design; avoid overgeneralizing the physical implementation.
  • Do not infer real-world security from a toy gate example: Actual authorization systems have many additional controls.

Objective-exam facts to remember

GateShort rule
AND1 only when both inputs are 1
OR1 when at least one input is 1
NOTReverses 0 and 1
NAND0 only when both inputs are 1
NOR1 only when both inputs are 0
XOR1 when the two inputs differ
XNOR1 when the two inputs match
Universal gatesNAND and NOR

Quick revision

  1. Boolean logic uses the two truth values 0 and 1.
  2. AND = both; OR = at least one; NOT = reverse.
  3. NAND and NOR reverse AND and OR.
  4. XOR = different; XNOR = same (for two inputs).
  5. Two Boolean inputs give four input combinations.

Practice questions — CA-04-04

1. For a two-input AND gate, when is the output 1?
A. Whenever A is 0
B. Only when A and B are both 1
C. Whenever B is 0
D. Only when A and B differ

2. What is the output of 1 OR 1 in Boolean logic?
A. 0
B. 1
C. 2
D. Undefined

3. A basic NOT gate has how many inputs?
A. 0
B. 1
C. 2
D. 4

4. What is the output of a two-input NAND gate when A=1 and B=1?
A. 0
B. 1
C. 2
D. 11

5. Which gate gives output 1 only when both inputs are 0?
A. AND
B. OR
C. NOR
D. XOR

6. For two inputs, the XOR gate produces 1 when:
A. The inputs are different
B. Both inputs are 1
C. Both inputs are 0
D. The inputs are equal

7. Which pair consists of universal logic gates?
A. AND and OR
B. XOR and XNOR
C. NOT and XOR
D. NAND and NOR

8. What is NOT 0?
A. 0
B. 1
C. 10
D. It depends on B

9. In a two-input truth table, how many input combinations must be considered?
A. 2
B. 3
C. 4
D. 8

10. Which statement correctly distinguishes OR from XOR?
A. OR and XOR always give the same result
B. OR gives 1 for inputs (1,1), while XOR gives 0
C. XOR gives 1 only for inputs (0,0)
D. OR always gives 0 when one input is 1

11. If A=1, B=0 and C=0, what is (A AND B) OR (NOT C)?
A. 0
B. 1
C. 2
D. Cannot be evaluated

12. A two-input XNOR gate outputs 1 when:
A. Only A is 1
B. Only B is 1
C. The two inputs are equal
D. The two inputs are different

Answers and explanations — CA-04-04

QCorrect answerWhy it is correct
1B. Both 1AND requires both conditions to hold; any zero input makes the result 0.
2B. 1Boolean OR is inclusive and returns 1 whenever either or both inputs are true.
3B. 1NOT is a one-input inverter.
4A. 0NAND reverses AND; AND(1,1)=1, so NAND(1,1)=0.
5C. NORNOR is NOT-OR; both inputs must be 0 for OR to give 0 and NOR to give 1.
6A. Inputs differXOR(0,1) and XOR(1,0) are 1; equal input pairs yield 0.
7D. NAND and NOREither gate type can implement other Boolean functions when combined appropriately.
8B. 1NOT inverts the one input value.
9C. 4Two binary inputs have 2²=4 possible combinations.
10B. Different results for (1,1)Inclusive OR returns 1; exclusive OR returns 0 when inputs match.
11B. 11 AND 0=0; NOT 0=1; finally 0 OR 1=1.
12C. Inputs are equalXNOR is the inverse of XOR, so it returns 1 for (0,0) or (1,1).