Truth Tables Examples in CS Thinking

Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Truth Tables.

This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in CS Thinking.

Concept Recap

A table listing every combination of boolean inputs and the resulting output for a logical expression.

Map out every possible True/False scenario to be sure you understand what a logical expression does.

Read the full concept explanation →

How to Use These Examples

  • Read the first worked example with the solution open so the structure is clear.
  • Try the practice problems before revealing each solution.
  • Use the related concepts and background knowledge badges if you feel stuck.

What to Focus On

Core idea: Truth tables exhaustively verify logical expressions and can reveal equivalences between different expressions.

Common stuck point: With n variables there are 2ⁿ rows — 3 variables means 8 rows, 4 means 16.

Sense of Study hint: To build a truth table, list all input variables as columns, then add a column for the output expression. Fill in all possible True/False combinations for the inputs (2n2^n rows for nn variables), then evaluate the expression for each row. Compare columns to check for logical equivalences.

Worked Examples

Example 1

medium
Build the truth table for (A AND B) OR C(A \text{ AND } B) \text{ OR } C and count the number of True rows.

Answer

55

First step

1
List 8 rows for (A,B,C)(A,B,C).

See the full worked solution + why-it-works coaching

SetupKey insightWhy it worksCommon pitfallConnection

Unlock answer keys One Family plan — every worked solution, all subjects

Example 2

medium
Using De Morgan, what expression is equivalent to NOT(A OR B)\text{NOT}(A \text{ OR } B)? Then verify on the A=T,B=FA=T,B=F row.

Example 3

medium
Use a truth table to decide whether A XOR AA \text{ XOR } A is equivalent to False (a contradiction).

Example 4

hard
Build the truth table for (A AND B) OR (NOT A AND NOT B)(A \text{ AND } B) \text{ OR } (\text{NOT } A \text{ AND NOT } B). What standard operator does it match?

Example 5

hard
Use a truth table to test whether A AND (NOT A OR B)A \text{ AND (NOT } A \text{ OR } B) simplifies to A AND BA \text{ AND } B.

Example 6

challenge
Verify with truth tables that NAND alone is functionally complete by expressing NOT, AND, and OR using only NAND.

Example 7

challenge
Two students disagree about whether (A OR B) AND (NOT A OR C)(A \text{ OR } B) \text{ AND } (\text{NOT } A \text{ OR } C) equals (A AND C) OR (NOT A AND B)(A \text{ AND } C) \text{ OR } (\text{NOT } A \text{ AND } B). Settle it with a truth table.

Practice Problems

Try these problems on your own first, then open the solution to compare your method.

Example 1

easy
How many rows does a truth table for 2 boolean variables have?

Example 2

easy
How many rows does a truth table for 3 boolean variables have?

Example 3

easy
In the truth table for A AND BA \text{ AND } B, how many of the 4 rows are True?

Example 4

easy
In the truth table for A OR BA \text{ OR } B, how many of the 4 rows are True?

Example 5

easy
In the truth table for A XOR BA \text{ XOR } B, how many of the 4 rows are True?

Example 6

easy
For the row A=True,B=FalseA=\text{True}, B=\text{False}, what is A AND BA \text{ AND } B?

Example 7

easy
How many rows does a truth table for 4 boolean variables have?

Example 8

easy
For the row A=FalseA=\text{False}, what is NOT A\text{NOT } A?

Example 9

medium
Build the truth table for NOT A OR B\text{NOT } A \text{ OR } B. For which of the 4 (A,B) rows is it False?

Example 10

medium
Are A AND BA \text{ AND } B and B AND AB \text{ AND } A equivalent? Justify using the truth table.

Example 11

medium
Verify De Morgan: do NOT(A AND B)\text{NOT(A AND B)} and (NOT A) OR (NOT B)\text{(NOT A) OR (NOT B)} match on all 4 rows?

Example 12

medium
Evaluate A AND (B OR C)A \text{ AND (B OR C)} for A=True,B=False,C=TrueA=\text{True}, B=\text{False}, C=\text{True}.

Example 13

medium
In an 8-row truth table for A,B,CA,B,C, how many rows have exactly one variable True?

Example 14

medium
Does A OR (A AND B)A \text{ OR (A AND B)} simplify to AA? Check with the truth table.

Example 15

medium
A truth table for an expression in 5 variables would have how many rows, and why is exhaustive checking still feasible by computer?

Example 16

challenge
Two students claim A XOR BA \text{ XOR } B equals (A OR B) AND NOT(A AND B)(A \text{ OR } B) \text{ AND NOT}(A \text{ AND } B). Verify across ALL 4 rows.

Example 17

challenge
An expression's truth table is True on exactly the rows (T,F) and (F,T) for variables (A,B). Identify the standard operator it represents and write it using AND/OR/NOT.

Example 18

challenge
How many distinct truth tables (boolean functions) exist for 2 input variables, and why?

Example 19

medium
Build the truth table for A AND NOT BA \text{ AND NOT } B. On which (A,B) row is it True?

Example 20

medium
Are A OR BA \text{ OR } B and B OR AB \text{ OR } A equivalent? Justify with the truth table.

Example 21

easy
How many rows does a truth table for 55 boolean variables have?

Example 22

easy
For A=True,B=TrueA=\text{True}, B=\text{True}, what is A OR BA \text{ OR } B?

Example 23

easy
For A=False,B=TrueA=\text{False}, B=\text{True}, what is A XOR BA \text{ XOR } B?

Example 24

easy
How many rows of the 4-row truth table for A XOR BA \text{ XOR } B are False?

Example 25

easy
Evaluate NOT(NOT A)\text{NOT}(\text{NOT } A) when A=TrueA=\text{True}.

Example 26

easy
Which row of the truth table for A AND BA \text{ AND } B is the only True row?

Example 27

easy
True or False: a truth table guarantees logical equivalence only if matching outputs appear on every row.

Example 28

medium
Evaluate A OR (NOT B)A \text{ OR (NOT } B \text{)} when A=False,B=TrueA=\text{False}, B=\text{True}.

Example 29

medium
Verify whether A AND (A OR B)A \text{ AND (A OR B)} is equivalent to AA using all 4 rows.

Example 30

medium
Evaluate NOT(A OR B)\text{NOT}(A \text{ OR } B) when A=False,B=FalseA=\text{False}, B=\text{False}.

Example 31

medium
In an 8-row truth table for A,B,CA,B,C, how many rows have all three variables True?

Example 32

medium
Evaluate (A XOR B) AND C(A \text{ XOR } B) \text{ AND } C for A=T,B=F,C=TA=T,B=F,C=T.

Example 33

medium
How many True rows does the truth table for A OR B OR CA \text{ OR } B \text{ OR } C have?

Example 34

medium
How many True rows does the truth table for A AND B AND CA \text{ AND } B \text{ AND } C have?

Example 35

hard
Are A AND (B OR C)A \text{ AND (B OR C)} and (A AND B) OR (A AND C)(A \text{ AND } B) \text{ OR } (A \text{ AND } C) equivalent? Justify on all 8 rows.

Example 36

hard
An expression on A,BA,B outputs True on rows (T,T)(T,T) and (F,F)(F,F), False elsewhere. Write a simple AND/OR/NOT expression matching it.

Example 37

hard
How many distinct boolean functions exist on 33 variables? Justify the count.

Example 38

hard
For n=10n=10 boolean inputs, exhaustive truth-table checking requires how many rows? Express as a power of two and a decimal.

Example 39

challenge
A 3-input majority function MAJ(A,B,C)(A,B,C) outputs True when at least two inputs are True. How many True rows does its truth table have, and write it in DNF.

Background Knowledge

These ideas may be useful before you work through the harder examples.

boolean logiclogical operators