← IGCSE Computer Science Paper 2

Tracing a counting algorithm

In a trace table, Count goes up by 1 only on rows where the condition is TRUE. If it is FALSE, Count stays the same. The final value of Count is what the OUTPUT shows.

Understanding Tracing a counting algorithm in IGCSE Computer Science Paper 2

What it does: If Mark is 40, Mark >= 50 is FALSE, so Count ← Count + 1 is skipped and Count is unchanged on that row. Count ← 0 is the first value in the Count column. Each TRUE row then adds 1 to it. A TRUE condition means Count ← Count + 1 runs, so 2 becomes 3. 9, 7 and 8 are greater than 5 (TRUE). 4 and 2 are FALSE and are not counted, so Count is 3.

Common mistakes: The IF line has no THEN. The condition is tested, and Pass only goes up when it is TRUE, so it must be written IF Mark[i] >= 50 THEN. A FOR loop sets its start value with the assignment arrow, not =. It should be FOR i ← 1 TO 6.

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 275–285) and word search (Modules 275–295).

Take this worksheet further — free with Cloodit

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

Learning
Duo
A trace table row shows Mark = 40 and the condition Mark >= 50 is FALSE. What happens to Count on that row?
Count stays the sameCount goes up by 1
Matches
Mark = 40 → condition (Mark >= 50) = TRUE, Count goes from 2 to 3
↓
40 is not greater than or equal to 50, so the condition is FALSE and Count should stay at 2
Applying
Meanings
Term
Count ← Count + 1
Meaning
In a trace table, Count goes up by 1 only on rows where the condition is TRUE. If it is FALSE, Count stays the same. The final value of Count is what the OUTPUT shows.
Practice
Count ← 0
Testing
Gaps
Count ← + 1
Check Answer
Spots
2FOR i ← 1 TO 5
3 IF Mark[i] >= 50

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

The 'Fox' badge — Cunning Debugger, 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. A trace table row shows Mark = 40 and the condition Mark >= 50 is FALSE. What happens to Count on that row?
A. Count stays the same ✓
B. Count goes up by 1
When the condition is FALSE, Count ← Count + 1 is skipped, so Count keeps its old value.
2. On a row where the condition is TRUE, Count was 2 on the row before. What is Count on this row?
A. 2
B. 3 ✓
A TRUE condition means Count ← Count + 1 runs, so 2 becomes 3.
3. Count ← 0. The marks 60, 45, 70 are checked with the condition Mark >= 50. What does OUTPUT Count show at the end?
A. 2 ✓
B. 3
Only 60 and 70 make the condition TRUE. 45 is FALSE, so it is not counted. Count ends as 2.
4. Count is 1 on the previous row. Which trace table row is correct for Mark = 45 with the condition Mark >= 50?
A. Mark 45 | Condition FALSE | Count 2
B. Mark 45 | Condition FALSE | Count 1 ✓
The condition is FALSE, so Count must be copied down unchanged as 1.
5. The OUTPUT Count statement comes after the loop has ended. Which statement is correct?
A. It shows the last value of Count in the trace table ✓
B. It shows the number of rows in the trace table
The final Count is the number of items that made the condition TRUE, not the number of items checked.

Match the Pairs

Count ← Count + 1 → In the trace table, Count goes up by 1 only on rows where the condition is TRUE
OUTPUT Count → Shows the final value of Count after the loop has finished, not the value on any one row
When the condition is FALSE, the counter stays the same, so the Count column repeats the previous value → IF Mark >= 50 THEN Count ← Count + 1 ENDIF
The counter must start at 0 so the first row of the trace table shows Count as 0 before any items are checked → Count ← 0
Mark = 40 → condition (Mark >= 50) = TRUE, Count goes from 2 to 3 → 40 is not greater than or equal to 50, so the condition is FALSE and Count should stay at 2
Final row of trace table: Count = 3, but OUTPUT Count shows 2 → The OUTPUT must show the final value of Count from the last row of the trace table, which is 3

Key Term

Count ← Count + 1
In a trace table, Count goes up by 1 only on rows where the condition is TRUE. If it is FALSE, Count stays the same. The final value of Count is what the OUTPUT shows.

Fill in the Blanks

1. IF Mark >= 50 THEN Count ← Count + 1 ENDIF
Hint: Type the name of the counter variable whose old value is being used, so it goes up only when the condition is TRUE.
2. IF Mark >= 50 THEN Count ← Count + 1 ENDIF
Hint: Type the arithmetic operator that makes the counter go up on a TRUE row of the trace table.
3. IF Mark >= 50 THEN Count ← Count + 1 ENDIF
Hint: Type the comparison operator meaning 'greater than or equal to'. It decides whether the condition is TRUE or FALSE.
4. NEXT Index OUTPUT Count
Hint: Type the keyword that displays the final count after the loop has finished.
5. Count ← 0 FOR Index ← 1 TO 5
Hint: Type the starting value of the counter, which is the first value in the Count column of the trace table.

Spot the Error

Question 1
A Pass ← 0
B FOR i ← 1 TO 5
C IF Mark[i] >= 50
D Pass ← Pass + 1
E ENDIF
F NEXT i
Line C — The IF line has no THEN. The condition is tested, and Pass only goes up when it is TRUE, so it must be written IF Mark[i] >= 50 THEN.
Question 2
A Count ← 0
B FOR i = 1 TO 6
C IF Score[i] > 10 THEN
D Count ← Count + 1
E ENDIF
F NEXT i
Line B — A FOR loop sets its start value with the assignment arrow, not =. It should be FOR i ← 1 TO 6.
Question 3
A Count ← 0
B FOR i ← 1 TO 10
C IF Colour[i] ← "Red" THEN
D Count ← Count + 1
E ENDIF
F NEXT i
Line C — The condition column in a trace table needs a comparison that is TRUE or FALSE. ← assigns a value instead. It should be IF Colour[i] = "Red" THEN.
Question 4
A Count ← 1
B FOR i ← 1 TO 5
C Count ← Count + 1
D NEXT i
E OUTPUT Count
Line A — Count must start at 0 before any items are counted. Starting at 1 makes every trace row and the final OUTPUT one too high. It should be Count ← 0.
Question 5
A Count ← 0
B FOR i ← 1 TO 5
C IF Mark[i] >= 50 THEN
D Count ← Count + Mark[i]
E ENDIF
F NEXT i
Line D — This adds the mark to Count, which is totalling. Counting adds 1 each time the condition is TRUE. It should be Count ← Count + 1.

Student with a class code? Join your class →