← IGCSE Computer Science Paper 2

STEP in a FOR loop

STEP sets how much the FOR counter changes each repeat. Without STEP the counter goes up by 1. A negative STEP, such as -1, makes the counter count down.

Understanding STEP in a FOR loop in IGCSE Computer Science Paper 2

What it does: With no STEP the default step is 1, so this loop gives the counter values 1, 2, 3, 4, 5. The values are 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 and 100. That is 11 values, because 0 counts as the first repeat. A negative STEP subtracts from the counter each repeat, so the counter counts down. A positive STEP makes it count up. Count takes the values 10, 9, 8, 7, 6, 5, 4, 3, 2, 1. That is 10 values, and both the start and end values are included. The correct line is FOR Number <- 0 TO 100 STEP 10, with the number straight after the word STEP.

Common mistakes: A FOR loop in Cambridge pseudocode ends with NEXT followed by the counter name, not ENDFOR. Line 3 should be NEXT Count. Without STEP the counter goes up by 1, so it can never count down from 10 to 1 and the loop would not run. It needs STEP -1: FOR Num <- 10 TO 1 STEP -1.

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 369–378) and word search (Modules 358–378).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which loop counts DOWN from 10 to 1?
FOR Count <- 10 TO 1 STEP -1FOR Count <- 10 TO 1
Matches
FOR Count <- 10 TO 1 OUTPUT Count NEXT Count
↓
There is no STEP -1, so the counter goes up by 1 by default. The start (10) is already past the end (1), so the loop body never runs.
Applying
Meanings
Term
FOR Count <- 10 TO 1 STEP -1
Meaning
STEP sets how much the FOR counter changes each repeat. Without STEP the counter goes up by 1. A negative STEP, such as -1, makes the counter count down.
Practice
FOR Count <- 10 TO 1 STEP -1
Testing
Gaps
FOR Number <- 0 TO 100 10
Check Answer
Spots
2 OUTPUT Count
3ENDFOR

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

The 'Space Turtle' badge — Speed in Zero-G, 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 loop counts DOWN from 10 to 1?
A. FOR Count <- 10 TO 1
B. FOR Count <- 10 TO 1 STEP -1 ✓
Without STEP the counter goes up by 1, so a loop that starts at 10 and ends at 1 would never run. STEP -1 makes the counter count down.
2. FOR Number <- 0 TO 100 STEP 10 What values does Number take?
A. 0, 10, 20, ... 100 ✓
B. 0, 1, 2, ... 100
STEP 10 adds 10 to the counter each repeat, so the values are 0, 10, 20 and so on up to 100.
3. A FOR loop has no STEP. How much does the counter change each repeat?
A. It goes up by 1 ✓
B. It goes up by 0
The default step is 1. If you leave STEP out, the counter increases by 1 each time.
4. How many times does this loop repeat? FOR Number <- 0 TO 100 STEP 10
A. 11 times ✓
B. 10 times
The values are 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 and 100. That is 11 values, because 0 counts as the first repeat.
5. Which STEP value makes the counter count down?
A. STEP 1
B. STEP -1 ✓
A negative STEP subtracts from the counter each repeat, so the counter counts down. A positive STEP makes it count up.

Match the Pairs

FOR Number <- 0 TO 100 STEP 10 → Counts up in tens: 0, 10, 20 and so on up to 100, giving 11 repeats
FOR Count <- 10 TO 1 STEP -1 → Counts down from 10 to 1, taking away 1 each repeat, giving 10 repeats
If STEP is left out, the counter goes up by 1 each repeat → FOR Index <- 1 TO 5
A negative STEP is needed when the start value is bigger than the end value → FOR Lap <- 8 TO 2 STEP -2
FOR Count <- 10 TO 1 OUTPUT Count NEXT Count → There is no STEP -1, so the counter goes up by 1 by default. The start (10) is already past the end (1), so the loop body never runs.
FOR Number <- 0 TO 100 STEP = 10 → STEP must be followed directly by the step value. The extra = sign is not valid in Cambridge pseudocode.

Key Term

FOR Count <- 10 TO 1 STEP -1
STEP sets how much the FOR counter changes each repeat. Without STEP the counter goes up by 1. A negative STEP, such as -1, makes the counter count down.

Fill in the Blanks

1. FOR Number <- 0 TO 100 STEP 10 OUTPUT Number NEXT Number
Hint: Type the keyword that sets how much the counter changes each repeat.
2. FOR Count <- 10 TO 1 STEP -1 OUTPUT Count NEXT Count
Hint: Type the negative step that makes the counter go down by one each repeat.
3. // Outputs 0, 20, 40, 60, 80, 100 FOR Number <- 0 TO 100 STEP 20 NEXT Number
Hint: Type the step size that matches the comment's sequence of counter values.
4. // Same as having no STEP at all FOR Index <- 1 TO 10 STEP 1 NEXT Index
Hint: Type the amount the counter goes up by when STEP is left out.
5. // Repeats 6 times: 0, 10, 20, 30, 40, 50 FOR Count <- 0 TO 50 STEP 10 NEXT Count
Hint: Type the end value that gives the number of repeats stated in the comment.

Spot the Error

Question 1
A FOR Count <- 10 TO 1 STEP -1
B OUTPUT Count
C ENDFOR
Line C — A FOR loop in Cambridge pseudocode ends with NEXT followed by the counter name, not ENDFOR. Line 3 should be NEXT Count.
Question 2
A DECLARE Num : INTEGER
B OUTPUT "Counting down"
C FOR Num <- 10 TO 1
D OUTPUT Num
E NEXT Num
Line C — Without STEP the counter goes up by 1, so it can never count down from 10 to 1 and the loop would not run. It needs STEP -1: FOR Num <- 10 TO 1 STEP -1.
Question 3
A OUTPUT "Evens"
B FOR Num <- 2 TO 10 STEP 2
C OUTPUT Num
D NEXT Count
Line D — NEXT must name the same counter as the FOR line. The counter is Num, so line 4 should be NEXT Num.
Question 4
A DECLARE Count : INTEGER
B FOR Count <- 10 TO 0 STEP 2
C OUTPUT Count
D NEXT Count
Line B — The counter starts at 10 and must go down to 0, so the STEP has to be negative. A positive STEP 2 would move away from 0. It should be STEP -2.
Question 5
A Total <- 0
B FOR Num <- 0 TO 100 STEP 10
C Total <- Total + Num
D NEXT Num STEP 10
E OUTPUT Total
Line D — STEP belongs on the FOR line only. The NEXT line just names the counter, so line 4 should be NEXT Num.

Student with a class code? Join your class →