← IGCSE Computer Science Paper 2

Tracing an IF statement

To trace an IF, work out if the condition is TRUE or FALSE for the current values, then follow only the THEN or ELSE path. Skipped statements get no row in the trace table.

Understanding Tracing an IF statement in IGCSE Computer Science Paper 2

What it does: The >= operator includes the limit, so 50 >= 50 is TRUE. With > the same value would give FALSE. The outer condition is traced first. If it is FALSE, the inner IF is never reached and gets no row. The condition is TRUE or FALSE. Follow just one path and ignore the other. Skipped statements are never run, so they leave no row in the trace table. 40 >= 50 is FALSE, so the ELSE path runs and Fail is output. Pass is never output. Only the path that is followed is traced. A skipped statement leaves no row.

Common mistakes: The text to display must be in double quotes. Without them, Pass is read as a variable name. It should be OUTPUT "Pass". Mark is 50, so the condition is TRUE and the THEN path runs. ELSE never has THEN after it. Only the IF line uses THEN. The line should be just ELSE. In the trace, ELSE is followed only when the condition is FALSE.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 83–92) and word search (Modules 71–92).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Mark is 50. Tracing IF Mark >= 50 THEN, what is the condition?
FALSE, because 50 is not greater than 50TRUE, because 50 is greater than or equal to 50
Matches
Mark = 50, IF Mark > 50 THEN: condition TRUE, so OUTPUT "Pass"
↓
50 > 50 is FALSE because > does not include the limit value, so the ELSE path is followed instead.
Applying
Meanings
Term
IF Mark >= 50 THEN
Meaning
To trace an IF, work out if the condition is TRUE or FALSE for the current values, then follow only the THEN or ELSE path. Skipped statements get no row in the trace table.
Practice
Mark ← 50
Testing
Gaps
IF Mark 50 THEN
Check Answer
Spots
2IF Mark >= 50 THEN
3 OUTPUT Pass

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Moose' badge — Tundra Champion, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Mark is 50. Tracing IF Mark >= 50 THEN, what is the condition?
A. TRUE, because 50 is greater than or equal to 50 ✓
B. FALSE, because 50 is not greater than 50
The >= operator includes the limit itself, so 50 >= 50 is TRUE and the THEN path is followed.
2. Mark is 50. Tracing IF Mark > 50 THEN, what is the condition?
A. TRUE, because 50 is equal to 50
B. FALSE, because 50 is not greater than 50 ✓
The > operator does not include the limit. 50 > 50 is FALSE, so the THEN path is skipped.
3. When tracing an IF with an ELSE, which statements do you follow?
A. Only the THEN path or only the ELSE path, never both ✓
B. Both the THEN path and the ELSE path, one after the other
The condition is TRUE or FALSE. Follow just one path and ignore the other.
4. The condition is FALSE and the IF has no ELSE. What do you do in the trace table?
A. Write a row for each statement inside the IF with blank values
B. Skip the statements inside the IF and give them no row ✓
Skipped statements are never run, so they leave no row in the trace table.
5. Score is 40. IF Score >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF. What goes in the OUTPUT column?
A. Fail ✓
B. Pass
40 >= 50 is FALSE, so the ELSE path runs and Fail is output. Pass is never output.

Match the Pairs

IF Mark >= 50 THEN → Check the condition with the current value of Mark. If it is TRUE, follow the THEN path only.
ELSE OUTPUT "Fail" → This statement is skipped when the condition is TRUE, so it gets no row in the trace table.
Checking a limit: when Mark is 50, the condition is TRUE because >= includes the limit value → IF Mark >= 50 THEN
A nested IF is traced one condition at a time. The inner IF is only checked if the outer condition is TRUE → IF Age >= 13 THEN IF Age < 20 THEN
Mark = 50, IF Mark > 50 THEN: condition TRUE, so OUTPUT "Pass" → 50 > 50 is FALSE because > does not include the limit value, so the ELSE path is followed instead.
Mark = 40, IF Mark >= 50 THEN: FALSE, so trace both OUTPUT "Pass" and OUTPUT "Fail" → Only one path is followed. When the condition is FALSE, only the ELSE statement is traced and the THEN statement gets no row.

Key Term

IF Mark >= 50 THEN
To trace an IF, work out if the condition is TRUE or FALSE for the current values, then follow only the THEN or ELSE path. Skipped statements get no row in the trace table.

Fill in the Blanks

1. IF Mark >= 50 THEN OUTPUT "Pass" ENDIF
Hint: Type the relational operator meaning greater than or equal to, so a mark of exactly 50 makes the condition true.
2. IF Temp > 30 THEN OUTPUT "Hot" ENDIF
Hint: Type the keyword that comes after the condition and begins the path followed when it is true.
3. IF Score < 40 THEN OUTPUT "Retry" ENDIF
Hint: Type the keyword that closes the IF statement, so the trace knows where the selection finishes.
4. Mark ← 50 IF Mark > 50 THEN // 50 > 50 is FALSE
Hint: Type the Boolean value of this condition when Mark is 50, so the THEN path is skipped.
5. IF Mark >= 50 THEN IF Mark >= 80 THEN OUTPUT "Merit"
Hint: Type the keyword that starts the inner decision inside the outer THEN path in a nested statement.

Spot the Error

Question 1
A Mark ← 50
B IF Mark >= 50 THEN
C OUTPUT Pass
D ENDIF
Line C — The text to display must be in double quotes. Without them, Pass is read as a variable name. It should be OUTPUT "Pass". Mark is 50, so the condition is TRUE and the THEN path runs.
Question 2
A Score ← 72
B IF Score >= 50 THEN
C Grade ← "Pass"
D ELSE THEN
E Grade ← "Fail"
F ENDIF
Line D — ELSE never has THEN after it. Only the IF line uses THEN. The line should be just ELSE. In the trace, ELSE is followed only when the condition is FALSE.
Question 3
A Age ← 16
B IF Age > 17 THEN
C Adult = TRUE
D ELSE
E Adult ← FALSE
F ENDIF
Line C — Assignment uses the arrow ←, not =. In pseudocode, = is for comparing values in a condition. It should be Adult ← TRUE. Age 16 makes the condition FALSE, so the ELSE row is the one recorded.
Question 4
A IF Mark => 50 THEN
B Result ← "Pass"
C ELSE
D Result ← "Fail"
E ENDIF
Line A — The 'greater than or equal to' operator is written >=, not =>. It should be IF Mark >= 50 THEN. A mark of exactly 50 makes this condition TRUE.
Question 5
A Mark ← 85
B IF Mark >= 50
C IF Mark >= 80 THEN
D OUTPUT "Merit"
E ENDIF
F ENDIF
Line B — The IF line is missing THEN. It should be IF Mark >= 50 THEN. The outer condition is checked first. Only if it is TRUE is the nested IF reached.

Student with a class code? Join your class →