← IGCSE Computer Science Paper 2

Input, process, output in one short program

A simple program's order: DECLARE variables, INPUT values, calculate with an assignment (←), then OUTPUT the result. Each step must come before the one that uses it.

Understanding Input, process, output in one short program in IGCSE Computer Science Paper 2

What it does: OUTPUT displays the stored result, and it comes last because TotalCost must already hold a value. DECLARE comes first so the variable exists and has a data type before INPUT or an assignment gives it a value. Each step must come before the step that uses it. Declare the variables, get the values, calculate, then show the result. Length and Width need values before they can be multiplied. Area is only output after it has been calculated. The missing step is the process step. An assignment calculates Area from Radius. INPUT would ask the user for Area instead of calculating it.

Common mistakes: A DECLARE statement needs a colon between the identifier and the data type. It should be DECLARE Area : INTEGER. The user must enter the price, not the total. Total is calculated from Price on the next line. Price never gets a value this way. It should be INPUT Price.

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 327–336) and word search (Modules 317–336).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which order is correct for a simple program?
DECLARE, INPUT, calculate with ←, OUTPUTOUTPUT, calculate with ←, INPUT, DECLARE
Matches
Total ← Price * Quantity INPUT Price INPUT Quantity OUTPUT Total
↓
The calculation comes before the INPUT lines, so Price and Quantity have no values yet when Total is worked out.
Applying
Meanings
Term
INPUT, ←, OUTPUT
Meaning
A simple program's order: DECLARE variables, INPUT values, calculate with an assignment (←), then OUTPUT the result. Each step must come before the one that uses it.
Practice
DECLARE Length : INTEGER
Testing
Gaps
Price : REAL
Check Answer
Spots
1DECLARE Side : INTEGER
2DECLARE Area INTEGER

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

The 'Desert Tortoise' badge — Desert Master, 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 order is correct for a simple program?
A. DECLARE, INPUT, calculate with ←, OUTPUT ✓
B. OUTPUT, calculate with ←, INPUT, DECLARE
Each step must come before the step that uses it. Declare the variables, get the values, calculate, then show the result.
2. A program finds the area of a rectangle. Which line goes BEFORE Area ← Length * Width?
A. INPUT Length and INPUT Width ✓
B. OUTPUT Area
Length and Width need values before they can be multiplied. Area is only output after it has been calculated.
3. Which line correctly calculates the total cost?
A. TotalCost ← Price * Quantity ✓
B. Price * Quantity ← TotalCost
In an assignment, the variable that receives the value goes on the left of ←. The calculation goes on the right.
4. The program is partly written. Which line completes it? INPUT Radius ??? OUTPUT Area
A. INPUT Area
B. Area ← 3.14 * Radius ^ 2 ✓
The missing step is the process step. An assignment calculates Area from Radius. INPUT would ask the user for Area instead of calculating it.
5. Which order gives the user a clear prompt?
A. INPUT Length then OUTPUT "Enter the length"
B. OUTPUT "Enter the length" then INPUT Length ✓
The prompt must be displayed before INPUT. Otherwise the user does not know what to type.

Match the Pairs

INPUT Width → Reads a value typed by the user and stores it in the variable Width, so it must come before any calculation that uses Width.
Area ← Width * Height → Processes the data: it calculates a result from the input values and stores it in the variable Area.
Show the result to the user as the last step of the program, after it has been calculated → OUTPUT "Total cost: ", TotalCost
Declare a variable with its data type before the program uses it to store a value → DECLARE Price : REAL
Total ← Price * Quantity INPUT Price INPUT Quantity OUTPUT Total → The calculation comes before the INPUT lines, so Price and Quantity have no values yet when Total is worked out.
INPUT Length INPUT Width OUTPUT Area Area ← Length * Width → OUTPUT is placed before Area is calculated, so it would display a variable that has no value yet.

Key Term

INPUT, ←, OUTPUT
A simple program's order: DECLARE variables, INPUT values, calculate with an assignment (←), then OUTPUT the result. Each step must come before the one that uses it.

Fill in the Blanks

1. DECLARE Price : REAL INPUT Price OUTPUT Price * 3
Hint: Type the keyword that creates a variable before it is used.
2. DECLARE Width : INTEGER INPUT Width OUTPUT Width * Width
Hint: Type the keyword that reads a value from the user into the variable.
3. INPUT Side Area ← Side * Side OUTPUT Area
Hint: Type the operator that multiplies two values.
4. INPUT Quantity Total ← Quantity * 2.5 OUTPUT Total
Hint: Type the assignment operator that stores the calculated result in Total.
5. INPUT Price Total ← Price * 3 OUTPUT Total
Hint: Type the keyword that displays the result to the user.

Spot the Error

Question 1
A DECLARE Side : INTEGER
B DECLARE Area INTEGER
C INPUT Side
D Area ← Side * Side
E OUTPUT Area
Line B — A DECLARE statement needs a colon between the identifier and the data type. It should be DECLARE Area : INTEGER.
Question 2
A DECLARE Price : REAL
B DECLARE Total : REAL
C INPUT Total
D Total ← Price * 3
E OUTPUT Total
Line C — The user must enter the price, not the total. Total is calculated from Price on the next line. Price never gets a value this way. It should be INPUT Price.
Question 3
A DECLARE Age : NUMBER
B DECLARE NextAge : INTEGER
C INPUT Age
D NextAge ← Age + 1
E OUTPUT NextAge
Line A — NUMBER is not a Cambridge pseudocode data type. A whole number age should be declared as INTEGER: DECLARE Age : INTEGER.
Question 4
A DECLARE Radius : REAL
B OUTPUT Enter the radius
C INPUT Radius
D OUTPUT Radius * Radius * 3.14
Line B — The text of a prompt is a string, so it must be in double quotes. It should be OUTPUT "Enter the radius".
Question 5
A DECLARE Length : INTEGER
B DECLARE Width : INTEGER
C INPUT Length
D INPUT Height
E OUTPUT Length * Width
Line D — Height was never declared, and Width would never get a value for the calculation. The line should be INPUT Width.

Student with a class code? Join your class →