← IGCSE Computer Science Paper 2

Counting in pseudocode

Adds 1 to Count each time an item meets a condition. Put it inside an IF in the loop, and set Count ← 0 before the loop starts so the count begins at zero.

Understanding Counting in pseudocode in IGCSE Computer Science Paper 2

What it does: The IF checks the condition for each item, so Count only goes up when the mark meets it. With no IF, the counter goes up on every pass, so it counts the loop passes (10) rather than the items that match a condition. A count starts at zero because nothing has been counted yet. Starting at 1 would make the final answer one too high. Assignment in IGCSE pseudocode uses the arrow ←. The = sign is for comparing values, not for storing them. The IF is true 4 times, so Count increases 4 times. The loop passes 10 times, but only the matches are counted.

Common mistakes: The IF statement is missing THEN. It should be IF Mark[Index] >= 50 THEN so the count is only increased when the condition is true. The counter must be set to 0 before the loop starts. Starting at 1 makes every final count one too high. It should be Count ← 0.

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 242–253) and word search (Modules 232–253).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which line should come BEFORE the loop when counting how many marks are 50 or more?
Count ← 1Count ← 0
Matches
FOR Index ← 1 TO 10 Count ← 0 IF Mark[Index] > 50 THEN Count ← Count + 1 ENDIF NEXT Index
↓
Count ← 0 is inside the loop, so the counter is reset to zero on every pass and the total is lost.
Applying
Meanings
Term
Count ← Count + 1
Meaning
Adds 1 to Count each time an item meets a condition. Put it inside an IF in the loop, and set Count ← 0 before the loop starts so the count begins at zero.
Practice
DECLARE Count : INTEGER
Testing
Gaps
Count ←
Check Answer
Spots
2FOR Index ← 1 TO 10
3 IF Mark[Index] >= 50

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

The 'Warthog' badge — Definition Digger, 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. Which line should come BEFORE the loop when counting how many marks are 50 or more?
A. Count ← 0 ✓
B. Count ← 1
A count starts at zero because nothing has been counted yet. Starting at 1 would make the final answer one too high.
2. Which statement adds one to the count?
A. Count ← Count + 1 ✓
B. Count = Count + 1
Assignment in IGCSE pseudocode uses the arrow ←. The = sign is for comparing values, not for storing them.
3. Where does Count ← Count + 1 go if you only want to count the marks that are 50 or more?
A. On its own line in the loop, outside any IF
B. Inside an IF that checks Mark >= 50, inside the loop ✓
Without the IF, the count goes up on every pass. It would then count all the items instead of only the matches.
4. A loop runs 20 times. Count ← Count + 1 is inside the loop but NOT inside an IF. What does Count hold at the end?
A. 20 (the number of passes) ✓
B. The number of items that meet the condition
Count goes up on every pass, so it counts passes. To count matches, put the increase inside an IF.
5. A loop runs 10 times and 4 items meet the condition. The increase is inside the IF. What is Count at the end?
A. 10
B. 4 ✓
The IF is true 4 times, so Count increases 4 times. The loop passes 10 times, but only the matches are counted.

Match the Pairs

Count ← 0 → Sets the counter to zero before the loop starts, so the count begins from nothing
Count ← Count + 1 → Adds 1 to the counter each time it runs, so it counts one more matching item
To count only the marks that are 50 or more, put the counting statement inside an IF within the loop → IF Mark >= 50 THEN Count ← Count + 1 ENDIF
To count how many times the loop passes (every item, not just matches), add 1 in the loop with no IF → FOR Index ← 1 TO 10 Passes ← Passes + 1 NEXT Index
FOR Index ← 1 TO 10 Count ← 0 IF Mark[Index] > 50 THEN Count ← Count + 1 ENDIF NEXT Index → Count ← 0 is inside the loop, so the counter is reset to zero on every pass and the total is lost.
Count ← 0 FOR Index ← 1 TO 10 Count ← Count + 1 IF Mark[Index] > 50 THEN OUTPUT Mark[Index] ENDIF NEXT Index → Count ← Count + 1 is outside the IF, so it counts every pass instead of only the items that meet the condition.

Key Term

Count ← Count + 1
Adds 1 to Count each time an item meets a condition. Put it inside an IF in the loop, and set Count ← 0 before the loop starts so the count begins at zero.

Fill in the Blanks

1. Count ← 0 FOR Index ← 1 TO 10 INPUT Mark
Hint: Type the starting value the counter must have before the loop begins.
2. FOR Index ← 1 TO 10 IF Mark >= 50 THEN Count ← Count + 1
Hint: Type the keyword that makes only the items meeting the condition get counted.
3. IF Mark >= 50 THEN Count ← Count + 1 ENDIF
Hint: Type the number added to the counter for each matching item.
4. IF Age >= 18 THEN Count ← Count + 1 ENDIF
Hint: Type the variable whose current value is increased by one.
5. IF Score > 80 THEN Count ← Count + 1 ENDIF
Hint: Type the keyword that closes the selection inside the loop.

Spot the Error

Question 1
A Count ← 0
B FOR Index ← 1 TO 10
C IF Mark[Index] >= 50
D Count ← Count + 1
E ENDIF
F NEXT Index
Line C — The IF statement is missing THEN. It should be IF Mark[Index] >= 50 THEN so the count is only increased when the condition is true.
Question 2
A Count ← 1
B FOR Index ← 1 TO 30
C IF Pass[Index] = TRUE THEN
D Count ← Count + 1
E ENDIF
F NEXT Index
Line A — The counter must be set to 0 before the loop starts. Starting at 1 makes every final count one too high. It should be Count ← 0.
Question 3
A Count ← 0
B FOR Index = 1 TO 10
C IF Score[Index] > 90 THEN
D Count ← Count + 1
E ENDIF
F NEXT Index
Line B — A FOR loop sets its counter with the assignment arrow, not =. It should be FOR Index ← 1 TO 10.
Question 4
A Count ← 0
B FOR Index ← 1 TO 10
C IF Speed[Index] > 70 THEN
D Count ← 1
E ENDIF
F NEXT Index
Line D — Count ← 1 just resets the count to 1 each time instead of adding to it. It should be Count ← Count + 1 so the count goes up by one for every match.
Question 5
A Count ← 0
B FOR Index ← 1 TO 10
C IF Mark[Index] ← 100 THEN
D Count ← Count + 1
E ENDIF
F NEXT Index
Line C — The arrow ← is for assignment. A condition must compare values using =. It should be IF Mark[Index] = 100 THEN.

Student with a class code? Join your class →