← IGCSE Computer Science Paper 2

Sequence

Statements are carried out one after another in the order they are written, from top to bottom, so changing the order can change the result.

Understanding Sequence in IGCSE Computer Science Paper 2

What it does: A gets its value before B copies it. If the first two lines were swapped, B would copy A before A had been given 5. Sequence means top to bottom, one statement at a time, in the order written. Values must be input before they are used in a calculation, and the calculation must be done before the result is output. The computer does not look ahead. It only uses what has been set by the lines above. Start at the first statement and work down, doing each statement in turn. A starts at 5, becomes 6 on line two, and line three outputs the current value, 6.

Common mistakes: Line 4 outputs Cost before it has been calculated. Statements run top to bottom, so the calculation Cost ← Area * 3 must come before OUTPUT Cost. Line 1 uses Num before it has been input. The INPUT Num statement must come first so that Num has a value when the calculation runs.

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 156–165) and word search (Modules 146–165).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which statement describes sequence?
The computer runs all the statements at the same timeStatements run one after another in the order they are written
Matches
Area ← Length * Width INPUT Length INPUT Width OUTPUT Area
↓
The calculation comes before the INPUT statements, so Length and Width have no values when Area is worked out. Move the calculation after both INPUTs.
Applying
Meanings
Term
sequence
Meaning
Statements are carried out one after another in the order they are written, from top to bottom, so changing the order can change the result.
Practice
DECLARE Price : REAL
Testing
Gaps
Price
Check Answer
Spots
3Area ← Length * Width
4OUTPUT Cost

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

The 'Giant Squid' badge — Nested Navigator, 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 statement describes sequence?
A. The computer runs all the statements at the same time
B. Statements run one after another in the order they are written ✓
Sequence means top to bottom, one statement at a time, in the order written.
2. In which order should this algorithm be written to add two numbers and show the answer?
A. INPUT A, INPUT B, Total ← A + B, OUTPUT Total ✓
B. OUTPUT Total, Total ← A + B, INPUT A, INPUT B
Values must be input before they are used in a calculation, and the calculation must be done before the result is output.
3. Total ← Price * 2 is written BEFORE INPUT Price. What happens?
A. The computer looks ahead and uses the value input on the next line
B. The calculation uses a value that has not been input yet, so the result is wrong ✓
The computer does not look ahead. It only uses what has been set by the lines above.
4. Two statements are swapped: OUTPUT Total now comes before Total ← A + B. What is output?
A. The old value of Total, not the new sum ✓
B. The new sum, because the calculation is done anyway
OUTPUT runs first, so it shows whatever Total held before the calculation was done.
5. Which way do you read an algorithm to follow its sequence?
A. From the top line to the bottom line ✓
B. From the bottom line to the top line
Start at the first statement and work down, doing each statement in turn.

Match the Pairs

INPUT Price Total ← Price * 2 OUTPUT Total → A sequence: the value is input first, then calculated, then output, in that order from top to bottom
OUTPUT Total Total ← Price * 2 INPUT Price → A sequence in the wrong order: Total is output before it has been calculated or Price has been input
Swapping two statements changes the result: here A is set to 5, then B copies A, so B is 5 → A ← 5 B ← A OUTPUT B
Reading an algorithm from top to bottom: the second assignment replaces the first value, so the output is 9 → X ← 4 X ← 9 OUTPUT X
Area ← Length * Width INPUT Length INPUT Width OUTPUT Area → The calculation comes before the INPUT statements, so Length and Width have no values when Area is worked out. Move the calculation after both INPUTs.
INPUT Mark OUTPUT Percent Percent ← Mark / 50 * 100 → OUTPUT is placed before the calculation, so Percent is displayed before it has been worked out. Swap the last two lines.

Key Term

sequence
Statements are carried out one after another in the order they are written, from top to bottom, so changing the order can change the result.

Fill in the Blanks

1. INPUT Price Total ← Price * 2 OUTPUT Total
Hint: Type the keyword that reads a value from the user. It must come before the calculation that uses the value.
2. INPUT Length Area ← Length * Length OUTPUT Area
Hint: Type the variable that stores the result worked out on the line above, so it can be output last.
3. Temp ← A A ← B B ← Temp
Hint: Type the variable that kept the old value of A before A was overwritten on the line above.
4. INPUT Price Tax ← Price * 0.2 OUTPUT Tax
Hint: Type the assignment symbol that stores the result of the calculation in Tax.
5. Total ← 10 Total ← Total * 2 OUTPUT Total
Hint: Type the arithmetic operator that multiplies, so the second line doubles the value set on the first line.

Spot the Error

Question 1
A INPUT Length
B INPUT Width
C Area ← Length * Width
D OUTPUT Cost
E OUTPUT Cost
Line D — Line 4 outputs Cost before it has been calculated. Statements run top to bottom, so the calculation Cost ← Area * 3 must come before OUTPUT Cost.
Question 2
A Double ← Num * 2
B Double ← Num * 2
C OUTPUT Double
Line A — Line 1 uses Num before it has been input. The INPUT Num statement must come first so that Num has a value when the calculation runs.
Question 3
A INPUT Price
B Tax ← Total * 0.2
C Total ← Price + Tax
D OUTPUT Total
Line B — Line 2 uses Total before it has been worked out on line 3. Tax should be calculated from Price, which was input on line 1.
Question 4
A Total ← 0
B INPUT A
C Total ← Total + A
D Total ← Total + B
E Total ← Total + B
F OUTPUT Total
Line D — Line 4 adds B to Total before B has been input. The INPUT B statement must come first, then the addition.
Question 5
A OUTPUT "Enter Celsius"
B OUTPUT Fahr
C Fahr ← Celsius * 9 / 5 + 32
D OUTPUT Fahr
Line B — Line 2 outputs Fahr before the value has been input and calculated. The INPUT must come first, then the calculation, then OUTPUT.

Student with a class code? Join your class →