← IGCSE Computer Science Paper 2

Describing the processes of a loop

State how many times the loop repeats or the condition it stops on, and what happens to the data each time round, e.g. each mark is added to Total.

Understanding Describing the processes of a loop in IGCSE Computer Science Paper 2

What it does: The loop runs from 1 to 5, which is 5 repeats, and Sum changes each time a Number is added. This is a condition-controlled loop. It stops when the condition is no longer true, not after a fixed number of times. Give the stopping condition and say what happens each time round (a new Password is input). Just naming the loop does not earn marks. State the repeat count or stopping condition and the changes to the data. A full description also gives the change in each pass, for example: each mark is added to Total.

Common mistakes: INPUT is a keyword that comes first, followed by the variable. It should be INPUT Mark, so each of the 5 marks is read and then added to Total. Count starts at 0, so Count > 10 is false straight away and the loop never runs. The loop repeats while Count < 10 and adds 1 to Count each time round.

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 216–231) and word search (Modules 188–231).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which is the better description of FOR Count ← 1 TO 5 with Total ← Total + Count?
The loop repeats 5 times and each time Count is added to TotalThe loop adds numbers together
Matches
Description: "The loop adds numbers to Total."
↓
It does not say how many times the loop repeats or when it stops, so it is too vague.
Applying
Meanings
Term
Describing a loop
Meaning
State how many times the loop repeats or the condition it stops on, and what happens to the data each time round, e.g. each mark is added to Total.
Practice
Total ← 0
Testing
Gaps
FOR Count ← 1 TO
Check Answer
Spots
2FOR Count ← 1 TO 5
3 Mark ← INPUT

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

The 'Starfish' badge — Five-Point Star, 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 is the better description of FOR Count ← 1 TO 5 with Total ← Total + Count?
A. The loop repeats 5 times and each time Count is added to Total ✓
B. The loop adds numbers together
A good description says how many times the loop repeats and what happens to the data each time round.
2. Which phrase correctly describes the repeat part of: WHILE Mark <> -1 DO ... ENDWHILE?
A. It repeats exactly 10 times
B. It repeats until the user enters -1 ✓
This is a condition-controlled loop. It stops when the condition is no longer true, not after a fixed number of times.
3. A FOR loop runs from 1 to 20. Which describes it best?
A. Condition-controlled: it repeats until a condition is met
B. Count-controlled: it repeats 20 times ✓
A FOR loop has set start and end values, so the number of repeats is known. This makes it count-controlled.
4. Which describes what happens to the data in: Total ← Total + Mark inside a loop?
A. Each mark entered is added to Total ✓
B. Total is set to the first mark only
Describe how the value changes in each pass. Here Total grows by the current Mark every time round.
5. Which is the better answer to 'Describe the loop'?
A. It repeats until Password is correct, asking for a new Password each time ✓
B. It is a loop that has a Password in it
Give the stopping condition and say what happens each time round (a new Password is input).

Match the Pairs

FOR Count ← 1 TO 10 Total ← Total + Count NEXT Count → Repeats exactly 10 times, and each time round the current value of Count is added to Total
WHILE Mark <> -1 DO Total ← Total + Mark INPUT Mark ENDWHILE → Repeats until the user enters -1, adding each mark to Total and then inputting the next mark
A count-controlled loop description gives the number of repeats: it repeats 5 times and each number input is added to Sum → FOR Index ← 1 TO 5 INPUT Number Sum ← Sum + Number NEXT Index
A condition-controlled loop description gives the stopping condition: it repeats until the password is correct, asking for a new password each time → REPEAT INPUT Password UNTIL Password = "Secret"
Description: "The loop adds numbers to Total." → It does not say how many times the loop repeats or when it stops, so it is too vague.
Description: "The loop repeats 10 times." → It does not say what happens to the data each time round, such as which value is added or changed.

Key Term

Describing a loop
State how many times the loop repeats or the condition it stops on, and what happens to the data each time round, e.g. each mark is added to Total.

Fill in the Blanks

1. FOR Count ← 1 TO 5 Total ← Total + Mark NEXT Count
Hint: Type the end value of the counter so the loop repeats once for each of the five marks.
2. WHILE Total < 100 DO Total ← Total + Mark ENDWHILE
Hint: Type the variable that holds the running total, so each mark is added to it every time round.
3. WHILE Count <= 5 DO Count ← Count + 1 ENDWHILE
Hint: Type the arithmetic operator that changes the counter each pass so the loop moves towards stopping.
4. FOR Count ← 1 TO 10 STEP 2 OUTPUT Count NEXT Count
Hint: Type the keyword that sets how much the counter changes by each time round the loop.
5. REPEAT Total ← Total + Mark UNTIL Total >= 100
Hint: Type the keyword that ends a condition-controlled loop and introduces the condition it stops on.

Spot the Error

Question 1
A Total ← 0
B FOR Count ← 1 TO 5
C Mark ← INPUT
D Total ← Total + Mark
E NEXT Count
Line C — INPUT is a keyword that comes first, followed by the variable. It should be INPUT Mark, so each of the 5 marks is read and then added to Total.
Question 2
A Count ← 0
B WHILE Count > 10 DO
C Count ← Count + 1
D ENDWHILE
Line B — Count starts at 0, so Count > 10 is false straight away and the loop never runs. The loop repeats while Count < 10 and adds 1 to Count each time round.
Question 3
A Total ← 0
B FOR Day ← 1 TO 7
C INPUT Steps
D Total ← Total + Day
E NEXT Day
Line D — Each pass should add the steps entered to Total, not the day number. It should be Total ← Total + Steps.
Question 4
A Attempts ← 0
B REPEAT
C INPUT Password
D Attempts ← Attempts - 1
E UNTIL Password = Secret
Line D — Attempts counts how many times the loop repeats until the password is correct, so it must go up by 1 each pass: Attempts ← Attempts + 1.
Question 5
A Total ← 0
B FOR Num ← 1 UNTIL 10
C Total ← Total + Num
D NEXT Num
E OUTPUT Total
Line B — A count-controlled loop uses FOR ... TO to give the start and end values. UNTIL belongs to REPEAT loops. It should be FOR Num ← 1 TO 10.

Student with a class code? Join your class →