← IGCSE Computer Science Paper 2

Writing a sequence in Cambridge pseudocode

A program made of statements like DECLARE, <-, INPUT and OUTPUT that run one after another from top to bottom, with no selection or iteration. Changing the order changes the result.

Understanding Writing a sequence in Cambridge pseudocode in IGCSE Computer Science Paper 2

What it does: DECLARE, INPUT and OUTPUT run in that order from top to bottom, and the program has no IF or loop. A sequence has no selection (IF) or iteration (loops). Each statement runs once, from top to bottom. A sequence follows input, then process, then output. You cannot output an answer before it has been worked out. The statements run in order. Total becomes 5, then 5 + 3 is stored back into Total, so it is 8. In B, OUTPUT runs before the addition, so it shows 4. Changing the order changes the output. A variable should be declared before it is used. Declare first, then assign with <-.

Common mistakes: The keyword INPUT must come first, followed by the variable name. The line should be INPUT Qty. A DECLARE statement uses a colon between the identifier and the data type. It should be DECLARE Age : INTEGER.

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 358–368) 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 program is a sequence?
INPUT Num, then IF Num > 5 THEN OUTPUT Num, then ENDIFINPUT Num, then Total <- Num * 2, then OUTPUT Total
Matches
OUTPUT Total Total <- 4 + 6
↓
OUTPUT comes before the assignment, so Total has no value when it is output. The two statements must be swapped.
Applying
Meanings
Term
sequence
Meaning
A program made of statements like DECLARE, <-, INPUT and OUTPUT that run one after another from top to bottom, with no selection or iteration. Changing the order changes the result.
Practice
DECLARE Price : REAL
Testing
Gaps
Price
Check Answer
Spots
3INPUT Price
4Qty INPUT

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

The 'Tree Frog' badge — Leap of Logic, 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 program is a sequence?
A. INPUT Num, then IF Num > 5 THEN OUTPUT Num, then ENDIF
B. INPUT Num, then Total <- Num * 2, then OUTPUT Total ✓
A sequence has no selection (IF) or iteration (loops). Each statement runs once, from top to bottom.
2. A program takes a number, doubles it and shows the answer. What is the correct order?
A. OUTPUT Answer, then Answer <- Num * 2, then INPUT Num
B. INPUT Num, then Answer <- Num * 2, then OUTPUT Answer ✓
A sequence follows input, then process, then output. You cannot output an answer before it has been worked out.
3. Which line is the PROCESS step in an input-process-output sequence?
A. Area <- Length * Width ✓
B. INPUT Length
The calculation is the process step. INPUT is the input step and OUTPUT is the output step.
4. What is OUTPUT Total after these lines run? Total <- 5 Total <- Total + 3
A. 8 ✓
B. 5
The statements run in order. Total becomes 5, then 5 + 3 is stored back into Total, so it is 8.
5. What happens if you swap these two lines? X <- 4 OUTPUT X
A. X has no value when it is output, so the output is wrong or an error ✓
B. The output is still 4 because the order does not matter
Order matters in a sequence. A variable must be given a value before OUTPUT can use it.

Match the Pairs

INPUT Price Total <- Price * 2 OUTPUT Total → A sequence of input, then process, then output: the statements run once each, in order, from top to bottom
Total <- Price * 2 INPUT Price OUTPUT Total → The order is wrong: Price is used in the calculation before it has been given a value from INPUT
A sequence program starts by declaring its variables, then takes input, then outputs a result → DECLARE Age : INTEGER INPUT Age OUTPUT Age + 1
A program with no selection or iteration is a pure sequence: every statement runs exactly once, in order → A <- 5 B <- A + 3 OUTPUT B
OUTPUT Total Total <- 4 + 6 → OUTPUT comes before the assignment, so Total has no value when it is output. The two statements must be swapped.
DECLARE Score : INTEGER Score = 10 OUTPUT Score → Assignment uses = instead of the arrow <-. It should be Score <- 10.

Key Term

sequence
A program made of statements like DECLARE, <-, INPUT and OUTPUT that run one after another from top to bottom, with no selection or iteration. Changing the order changes the result.

Fill in the Blanks

1. DECLARE Price : INTEGER INPUT Price OUTPUT Price
Hint: Type the keyword that reads a value from the user into a variable
2. INPUT Price Total ← Price * 3 OUTPUT Total
Hint: Type the arithmetic operator used for multiplication
3. Count ← 0 Count ← Count + 1 OUTPUT Count
Hint: Type the assignment operator that stores a value in a variable
4. DECLARE Name : STRING INPUT Name OUTPUT Name
Hint: Type the keyword that creates a variable before it is used
5. INPUT Mins Secs ← Mins * 60 OUTPUT Secs
Hint: Type the keyword that displays the final result on screen

Spot the Error

Question 1
A DECLARE Price : REAL
B DECLARE Qty : INTEGER
C INPUT Price
D Qty INPUT
E OUTPUT Price * Qty
Line D — The keyword INPUT must come first, followed by the variable name. The line should be INPUT Qty.
Question 2
A DECLARE Age = INTEGER
B INPUT Age
C Age <- Age + 1
D OUTPUT Age
Line A — A DECLARE statement uses a colon between the identifier and the data type. It should be DECLARE Age : INTEGER.
Question 3
A DECLARE Cost : REAL
B INPUT Cost
C OUTPUT "Cost: " Cost
Line C — Items in an OUTPUT statement must be separated by commas. It should be OUTPUT "Cost: ", Cost.
Question 4
A DECLARE Total : INTEGER
B Total = 10 + 5
C Total <- Total * 2
D OUTPUT Total
Line B — Assignment uses the arrow <-. The = sign is a comparison operator in Cambridge pseudocode. It should be Total <- 10 + 5.
Question 5
A DECLARE Num : INTEGER
B INPUT Num
C Num := Num * 2
D OUTPUT Num
Line C — Cambridge pseudocode assigns with <-, not :=. The line should be Num <- Num * 2.

Student with a class code? Join your class →