← IGCSE Computer Science Paper 2

Counting in Cambridge pseudocode

Adds 1 to the counter variable Count each time it runs inside a loop. Set Count ← 0 before the loop starts, so Count ends up holding how many times the loop ran.

Understanding Counting in Cambridge pseudocode in IGCSE Computer Science Paper 2

What it does: Count ← 0 placed before the loop gives the counter a starting value, so the first pass adds to 0. In Cambridge pseudocode the variable being changed goes on the left of the ← arrow. The new value goes on the right. A counter holds whole numbers, so its data type is INTEGER. A STRING stores text, which cannot be added to. Count goes 0 → 1 → 2 → 3 → 4 → 5. It increases once per pass, and there are 5 passes. The sentinel only signals the end, so it should not be counted. Count goes inside the loop and runs only for valid values.

Common mistakes: A FOR loop sets its counter with the assignment arrow, not =. The line should be FOR i ← 1 TO 10. A WHILE loop uses DO, not THEN (THEN belongs to IF). The line should be WHILE Num <> -1 DO.

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
Which line correctly adds one to a counter called Count?
Count ← Count + 1Count + 1 ← Count
Matches
FOR i ← 1 TO 10 Count ← 0 Count ← Count + 1 NEXT i
↓
Count is reset to 0 inside the loop, so it is wiped on every pass and ends as 1. Count ← 0 must go before the loop.
Applying
Meanings
Term
Count ← Count + 1
Meaning
Adds 1 to the counter variable Count each time it runs inside a loop. Set Count ← 0 before the loop starts, so Count ends up holding how many times the loop ran.
Practice
DECLARE Count : INTEGER
Testing
Gaps
DECLARE Count :
Check Answer
Spots
2Count ← 0
3FOR i = 1 TO 10

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

The 'Sea Dragon' badge — OOP Pioneer, 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 correctly adds one to a counter called Count?
A. Count ← Count + 1 ✓
B. Count + 1 ← Count
In Cambridge pseudocode the variable being changed goes on the left of the ← arrow. The new value goes on the right.
2. Which line should come BEFORE the loop starts so a counter begins correctly?
A. Count ← 0 ✓
B. Count ← Count + 1
The counter must be set to 0 before the loop. Otherwise it starts with no known value and the final count will be wrong.
3. Which declaration is correct for a counter that holds whole numbers?
A. DECLARE Count : STRING
B. DECLARE Count : INTEGER ✓
A counter holds whole numbers, so its data type is INTEGER. A STRING stores text, which cannot be added to.
4. Where does Count ← Count + 1 go to count the number of times a loop runs?
A. Inside the loop, so it runs on every pass ✓
B. After the loop, so it runs once at the end
Placed inside the loop, it adds 1 on each pass. After the loop it would only add 1 once, no matter how many passes there were.
5. A FOR loop runs 5 times and Count starts at 0. Count ← Count + 1 is the only line inside the loop. What is Count at the end?
A. 6
B. 5 ✓
Count goes 0 → 1 → 2 → 3 → 4 → 5. It increases once per pass, and there are 5 passes.

Match the Pairs

DECLARE Count : INTEGER → Creates an integer variable called Count to hold the number of times something happens
Count ← Count + 1 → Adds 1 to the current value of Count each time this line runs inside the loop
The counter must be set to zero before the loop starts so counting begins from nothing → Count ← 0
A REPEAT loop that counts how many numbers are entered before the sentinel -1 is typed → REPEAT INPUT Num IF Num <> -1 THEN Count ← Count + 1 UNTIL Num = -1
FOR i ← 1 TO 10 Count ← 0 Count ← Count + 1 NEXT i → Count is reset to 0 inside the loop, so it is wiped on every pass and ends as 1. Count ← 0 must go before the loop.
Count ← 0 WHILE Num <> -1 DO INPUT Num Count ← Count ENDWHILE → Count ← Count never changes the counter. It must be Count ← Count + 1 so that 1 is added on each pass.

Key Term

Count ← Count + 1
Adds 1 to the counter variable Count each time it runs inside a loop. Set Count ← 0 before the loop starts, so Count ends up holding how many times the loop ran.

Fill in the Blanks

1. DECLARE Count : INTEGER Count ← 0
Hint: Type the data type used for whole numbers.
2. Count ← 0 FOR Index ← 1 TO 5 Count ← Count + 1
Hint: Type the starting value the counter is set to before the loop begins.
3. FOR Index ← 1 TO 10 Count ← Count + 1 NEXT Index
Hint: Type the arithmetic operator that adds one to the counter.
4. WHILE Num <> -1 DO Count ← Count + 1 ENDWHILE
Hint: Type the keyword that closes a WHILE loop.
5. REPEAT Count ← Count + 1 UNTIL Num = -1
Hint: Type the counter variable that is being increased by one.

Spot the Error

Question 1
A DECLARE Count : INTEGER
B Count ← 0
C FOR i = 1 TO 10
D Count ← Count + 1
E NEXT i
Line C — A FOR loop sets its counter with the assignment arrow, not =. The line should be FOR i ← 1 TO 10.
Question 2
A Count ← 0
B INPUT Num
C WHILE Num <> -1 THEN
D Count ← Count + 1
E INPUT Num
F ENDWHILE
Line C — A WHILE loop uses DO, not THEN (THEN belongs to IF). The line should be WHILE Num <> -1 DO.
Question 3
A Count ← 0
B REPEAT
C Count ← Count - 1
D INPUT Guess
E UNTIL Guess = Secret
Line C — Counting adds 1 each pass. Subtracting 1 makes Count go down instead of up. It should be Count ← Count + 1.
Question 4
A DECLARE Count : INTEGER
B Count ← 0
C FOR i ← 1 TO 8
D Count ← Count + i
E NEXT i
F OUTPUT Count
Line D — Counting always adds exactly 1, not the loop variable i. Adding i would build a total instead. It should be Count ← Count + 1.
Question 5
A DECLARE Count : INTEGER
B Count ← 1
C FOR i ← 1 TO 5
D INPUT Mark
E Count ← Count + 1
F NEXT i
Line B — The counter must start at 0 before the loop. Starting at 1 makes the final count one too high. It should be Count ← 0.

Student with a class code? Join your class →