← IGCSE Computer Science Paper 2

FOR loop with STEP (7a)

Used in a FOR loop to set how much the loop variable changes each time. STEP 2 counts in twos and STEP -1 counts down. The loop stops when the value goes past the end.

Understanding FOR loop with STEP (7a) in IGCSE Computer Science Paper 2

What it does: STEP -1 reduces the loop variable by 1 each time, so the loop counts down from 10 to 0. The loop stops when the value goes past the end value. 10 is greater than 9, so it is not used. The default STEP is 1, so FOR I ← 1 TO 5 counts 1, 2, 3, 4, 5. Counting up from 1 to 9 needs a positive step. A negative step moves the value in the wrong direction.

Common mistakes: The keyword is STEP, not STEPS. The line should be FOR Count ← 0 TO 10 STEP 2. To count down from 10 to 1 the step must be negative. With STEP 1 the value starts past the end, so the loop never runs. It should be 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 37–46) and word search (Modules 27–46).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which FOR loop counts up in twos?
FOR Count ← 2 TO 10 STEP 10FOR Count ← 2 TO 10 STEP 2
Matches
FOR Count ← 10 TO 1 STEP 1
↓
The loop is meant to count down, but STEP 1 makes the value go up, so it moves away from the end value. It should use STEP -1.
Applying
Meanings
Term
STEP
Meaning
Used in a FOR loop to set how much the loop variable changes each time. STEP 2 counts in twos and STEP -1 counts down. The loop stops when the value goes past the end.
Practice
FOR Count ← 5 TO 1 STEP -1
Testing
Gaps
FOR Count ← 0 TO 10 2
Check Answer
Spots
1FOR Count ← 0 TO 10 STEPS 2
2 OUTPUT Count

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

The 'Chameleon' badge — Type Shifter, 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 FOR loop counts up in twos?
A. FOR Count ← 2 TO 10 STEP 2 ✓
B. FOR Count ← 2 TO 10 STEP 10
STEP 2 adds 2 to the loop variable each time, so it takes the values 2, 4, 6, 8, 10.
2. Which FOR loop counts down from 5 to 1?
A. FOR Count ← 5 TO 1 STEP -1 ✓
B. FOR Count ← 5 TO 1 STEP 1
A negative STEP makes the loop variable go down. STEP -1 takes away 1 each time. With STEP 1 the loop would not run, because 5 is already past 1.
3. What does STEP do in a FOR loop?
A. It sets how many times the loop body is written in the code
B. It sets how much the loop variable changes each time ✓
STEP is the amount added to the loop variable after each pass. If STEP is left out, it is 1 by default.
4. What values does FOR X ← 1 TO 9 STEP 3 give?
A. 1, 4, 7, 10
B. 1, 4, 7 ✓
The loop stops when the value goes past the end value. 10 is greater than 9, so it is not used.
5. A loop starts at 10 and ends at 0. Which STEP is needed?
A. STEP -2 ✓
B. STEP 2
When the start value is bigger than the end value, STEP must be negative. A positive STEP would move away from the end value.

Match the Pairs

FOR Count ← 2 TO 10 STEP 2 → Count goes 2, 4, 6, 8, 10 because the step makes it increase by 2 each time
FOR Count ← 5 TO 1 STEP -1 → Count goes 5, 4, 3, 2, 1 because the negative step makes it decrease by 1 each time
To count down from 10 to 0 in a FOR loop, the step must be negative → FOR Number ← 10 TO 0 STEP -1
To output only the even numbers from 2 to 20, the loop uses a step of 2 → FOR Number ← 2 TO 20 STEP 2
FOR Count ← 10 TO 1 STEP 1 → The loop is meant to count down, but STEP 1 makes the value go up, so it moves away from the end value. It should use STEP -1.
FOR Count ← 1 TO 9 STEP -2 → The step is negative, so the value goes down from 1 and never reaches 9. It should be STEP 2 to count up in twos.

Key Term

STEP
Used in a FOR loop to set how much the loop variable changes each time. STEP 2 counts in twos and STEP -1 counts down. The loop stops when the value goes past the end.

Fill in the Blanks

1. FOR Count ← 0 TO 10 STEP 2 OUTPUT Count NEXT Count
Hint: Type the keyword that sets how much the loop variable changes each time.
2. FOR Count ← 10 TO 1 STEP -1 OUTPUT Count NEXT Count
Hint: Type the step value that makes the loop count down one at a time.
3. FOR Num ← 2 TO 10 STEP 2 OUTPUT Num NEXT Num
Hint: Type the step value that makes the loop go through the even numbers from 2 to 10.
4. FOR Count ← 5 TO 1 STEP -1 OUTPUT Count NEXT Count
Hint: Type the loop variable name that must follow NEXT.
5. FOR Count ← 20 TO 0 STEP -5 OUTPUT Count NEXT Count
Hint: Type the keyword that comes before the end value, where the loop stops.

Spot the Error

Question 1
A FOR Count ← 0 TO 10 STEPS 2
B OUTPUT Count
C NEXT Count
Line A — The keyword is STEP, not STEPS. The line should be FOR Count ← 0 TO 10 STEP 2.
Question 2
A OUTPUT "Countdown"
B FOR Num ← 10 TO 1 STEP 1
C OUTPUT Num
D NEXT Num
Line B — To count down from 10 to 1 the step must be negative. With STEP 1 the value starts past the end, so the loop never runs. It should be STEP -1.
Question 3
A Total ← 0
B FOR Num ← 2 TO 10 STEP 2
C Total ← Total + Num
D NEXT Total
Line D — NEXT must name the loop variable, which is Num, not Total. The line should be NEXT Num.
Question 4
A DECLARE Num : INTEGER
B FOR Num ← 10 TO 0 STEP -2
C OUTPUT Number
D NEXT Num
Line C — The loop variable is Num, so Number is a different identifier that was never declared. The line should be OUTPUT Num.
Question 5
A Total ← 0
B FOR Count ← 1 TO 9 STEP 2
C Total ← Total + STEP
D NEXT Count
Line C — STEP is a keyword that sets the size of the change. It is not a value you can add. The loop variable Count holds the current value, so it should be Total ← Total + Count.

Student with a class code? Join your class →