← IGCSE Computer Science Paper 2

Using the FOR counter inside the loop

Uses the FOR counter inside the loop body. Count holds a new value on each repeat, so this outputs a times table. Never change Count inside the loop; after the loop it keeps its last value.

Understanding Using the FOR counter inside the loop in IGCSE Computer Science Paper 2

What it does: The body only reads Count to output a calculation and never assigns a new value to it, which is the correct way to use the counter. Count starts at 1 and goes up by 1 on each repeat, so OUTPUT Count shows 1, then 2, then 3. On repeat 1 Count is 1, so 1 * 7 = 7. On repeat 2 Count is 2, so 2 * 7 = 14. On the 3rd repeat Count holds 3, so Count * 7 = 21. FOR...NEXT updates the counter for you. Writing your own update in the body is a mistake.

Common mistakes: The FOR loop gives the counter its start value with the assignment arrow <-, not =. It should be FOR Count <- 1 TO 5. The loop counter is called Count, so Counter is a different variable that was never given a value. It should be OUTPUT Count * 7.

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 379–388) and word search (Modules 379–398).

Take this worksheet further — free with Cloodit

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

Learning
Duo
What does this output? FOR Count ← 1 TO 3 / OUTPUT Count / NEXT Count
1, 2, 3 (a new value each repeat)3, 3, 3 (the final value every time)
Matches
FOR Count <- 1 TO 5 Count <- Count + 1 OUTPUT Count NEXT Count
↓
The counter is changed inside the loop with an assignment. The FOR loop controls Count, so the body must never assign to it.
Applying
Meanings
Term
OUTPUT Count * 7
Meaning
Uses the FOR counter inside the loop body. Count holds a new value on each repeat, so this outputs a times table. Never change Count inside the loop; after the loop it keeps its last value.
Practice
FOR Count ← 1 TO 12
Testing
Gaps
OUTPUT
Check Answer
Spots
1FOR Count = 1 TO 5
2 OUTPUT Count

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

The 'Camel' badge — Endurance 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. What does this output? FOR Count ← 1 TO 3 / OUTPUT Count / NEXT Count
A. 1, 2, 3 (a new value each repeat) ✓
B. 3, 3, 3 (the final value every time)
Count starts at 1 and goes up by 1 on each repeat, so OUTPUT Count shows 1, then 2, then 3.
2. FOR Count ← 1 TO 4 / OUTPUT Count * 7 / NEXT Count. What are the first two values output?
A. 7 then 14 ✓
B. 7 then 7
On repeat 1 Count is 1, so 1 * 7 = 7. On repeat 2 Count is 2, so 2 * 7 = 14.
3. Which loop body outputs the 7 times table from 1 * 7 to 12 * 7?
A. OUTPUT 12 * 7 (inside FOR Count ← 1 TO 12)
B. OUTPUT Count * 7 (inside FOR Count ← 1 TO 12) ✓
The body must use Count in the calculation. OUTPUT 12 * 7 ignores the counter and prints 84 twelve times.
4. On the 3rd repeat of FOR Count ← 1 TO 10 with OUTPUT Count * 7, what is output?
A. 21 ✓
B. 7
On the 3rd repeat Count holds 3, so Count * 7 = 21.
5. Which statement should NOT appear inside a FOR Count loop body?
A. OUTPUT Count * 7
B. Count ← Count + 2 ✓
The FOR loop changes Count by itself. Assigning to Count inside the body interferes with the loop. Only read it, for example to output it or use it in a calculation.

Match the Pairs

FOR Count <- 1 TO 5 OUTPUT Count NEXT Count → Outputs the counter's value on each repeat, so it displays 1, 2, 3, 4, 5, one number per line
OUTPUT Count * 7 → Uses the counter in a calculation inside the loop, so each repeat outputs the next multiple of 7 (a times table)
The counter must not be changed by an assignment inside the loop body; the FOR loop controls it → FOR Count <- 1 TO 12 OUTPUT Count * 7 NEXT Count
After the loop finishes, the counter keeps its last value, so it can be output after NEXT → FOR Count <- 1 TO 3 OUTPUT Count NEXT Count OUTPUT Count
FOR Count <- 1 TO 5 Count <- Count + 1 OUTPUT Count NEXT Count → The counter is changed inside the loop with an assignment. The FOR loop controls Count, so the body must never assign to it.
FOR Count <- 1 TO 12 OUTPUT Count * 7 NEXT Count OUTPUT 7 → The times table uses a fixed value instead of the counter, so it does not show a new multiple on each repeat.

Key Term

OUTPUT Count * 7
Uses the FOR counter inside the loop body. Count holds a new value on each repeat, so this outputs a times table. Never change Count inside the loop; after the loop it keeps its last value.

Fill in the Blanks

1. FOR Count ← 1 TO 5 OUTPUT Count NEXT Count
Hint: Type the counter variable that holds a new value on each repeat.
2. FOR Count ← 1 TO 12 OUTPUT Count * 7 NEXT Count
Hint: Type the operator that multiplies the counter by 7 to make a times table.
3. FOR Count ← 1 TO 12 OUTPUT Count * 7 NEXT Count
Hint: Type the name of the counter variable that closes the loop.
4. FOR Count ← 1 TO 12 OUTPUT Count * 7 NEXT Count
Hint: Type the keyword that moves the counter on and ends the loop body. Never assign to the counter inside the loop.
5. FOR Count ← 1 TO 12 OUTPUT Count * 7 NEXT Count
Hint: Type the starting value of the counter so the table begins with one lot of 7.

Spot the Error

Question 1
A FOR Count = 1 TO 5
B OUTPUT Count
C NEXT Count
Line A — The FOR loop gives the counter its start value with the assignment arrow <-, not =. It should be FOR Count <- 1 TO 5.
Question 2
A FOR Count <- 1 TO 12
B OUTPUT Counter * 7
C NEXT Count
Line B — The loop counter is called Count, so Counter is a different variable that was never given a value. It should be OUTPUT Count * 7.
Question 3
A FOR Count <- 1 UNTIL 10
B OUTPUT Count * 3
C NEXT Count
Line A — A FOR loop uses the keyword TO before the end value, not UNTIL. UNTIL belongs to REPEAT...UNTIL. It should be FOR Count <- 1 TO 10.
Question 4
A FOR Count <- 1 TO 5
B OUTPUT Count * 2
C NEXT Total
Line C — NEXT must name the same counter as the FOR line. The counter is Count, so it should be NEXT Count.
Question 5
A Total <- 0
B FOR Count <- 1 TO 4
C Total <- Total + Count
D Count <- Count + 1
E NEXT Count
Line D — The counter must never be changed inside the loop, because the FOR loop already adds 1 each repeat. This line would break the counting. It should be OUTPUT Total.

Student with a class code? Join your class →