← IGCSE Computer Science Paper 2

Reading a problem to plan an algorithm

Plan before coding: read the problem, list what is input, what must be calculated or decided, and what is output. Then pick variables and spot repeats and decisions.

Understanding Reading a problem to plan an algorithm in IGCSE Computer Science Paper 2

What it does: Spotting 'enter 30 marks' as a repeat tells you to plan a FOR loop with 30 iterations. Words like 'if' in the problem show a decision. In pseudocode this becomes an IF statement with a condition. The mark is typed in by the user, so it is the input. PASS is the output that the algorithm produces. Planning first means you know what data you need and what the algorithm must produce, so you make fewer mistakes. Calculating or deciding is the process. Showing the result on the screen is the output. Doing something 30 times means a loop is needed. A FOR loop fits because the number of repeats is known.

Common mistakes: An average can have decimal places, so the variable that stores the result must be REAL, not INTEGER. It should be DECLARE Average : REAL. The process is to add up the prices that were input. Item is only the loop counter. The line should be Total ← Total + 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 254–264) and word search (Modules 254–274).

Take this worksheet further — free with Cloodit

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

Learning
Duo
A problem says: 'Read a student's test mark and output PASS if it is 50 or more.' What is the INPUT?
The test markThe word PASS
Matches
DECLARE Total : STRING
↓
Total will hold a calculated sum of marks, so it needs a numeric data type such as INTEGER, not STRING.
Applying
Meanings
Term
Input, Process, Output
Meaning
Plan before coding: read the problem, list what is input, what must be calculated or decided, and what is output. Then pick variables and spot repeats and decisions.
Practice
// Input: Mark1, Mark2 (INTEGER)
Testing
Gaps
Mark1
Check Answer
Spots
1DECLARE Average : REAL
2DECLARE Average : INTEGER

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

The 'Moose' badge — Tundra Champion, 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. A problem says: 'Read a student's test mark and output PASS if it is 50 or more.' What is the INPUT?
A. The word PASS
B. The test mark ✓
The mark is typed in by the user, so it is the input. PASS is the output that the algorithm produces.
2. Which is the better first step before writing an algorithm?
A. Read the problem and list the inputs, processes and outputs ✓
B. Start typing pseudocode straight away and fix it later
Planning first means you know what data you need and what the algorithm must produce, so you make fewer mistakes.
3. A problem says: 'Calculate the total cost of 5 items and output the total.' Which part is the PROCESS?
A. Showing the total on the screen
B. Adding the 5 prices to find the total ✓
Calculating or deciding is the process. Showing the result on the screen is the output.
4. When underlining a problem, what should you underline as outputs?
A. What the algorithm must display or give back, such as the average ✓
B. What the user must type in, such as each mark
Outputs are the results shown to the user. Data that the user types in is the input.
5. A problem says: 'Input 30 marks and output the highest.' Which words show a REPEAT is needed?
A. Input 30 marks ✓
B. output the highest
Doing something 30 times means a loop is needed. A FOR loop fits because the number of repeats is known.

Match the Pairs

INPUT Mark → An input found by underlining what the user enters, such as a mark in the problem
OUTPUT Average → An output found by underlining what the problem says must be displayed to the user
The problem says 'enter 30 marks', so it needs a repeat. Plan a loop that runs 30 times. → FOR Count ← 1 TO 30
The problem says 'if the mark is 50 or more, pass', so it needs a decision. Plan a selection. → IF Mark >= 50 THEN
DECLARE Total : STRING → Total will hold a calculated sum of marks, so it needs a numeric data type such as INTEGER, not STRING.
OUTPUT Average Average ← Total / Count INPUT Total → The order is wrong: the plan is input, then process, then output. The output comes first and the input comes last.

Key Term

Input, Process, Output
Plan before coding: read the problem, list what is input, what must be calculated or decided, and what is output. Then pick variables and spot repeats and decisions.

Fill in the Blanks

1. INPUT Mark1 INPUT Mark2 OUTPUT (Mark1 + Mark2) / 2
Hint: Type the keyword that reads a value from the user. This is the input step of the plan.
2. // Price of one item in dollars and cents DECLARE Price : REAL
Hint: Type the data type for a number that can have decimal places.
3. Total ← Price * Quantity OUTPUT Total
Hint: Type the variable that holds the calculated result, so it can be output.
4. FOR Count ← 1 TO 10 INPUT Mark NEXT Count
Hint: Type the keyword that gives the end value of a loop for a task that repeats a set number of times.
5. IF Mark >= 50 THEN OUTPUT "Pass" ENDIF
Hint: Type the relational operator for the decision 'the mark is 50 or more'.

Spot the Error

Question 1
A DECLARE Average : REAL
B DECLARE Average : INTEGER
C INPUT Mark2
D Average ← (Mark1 + Mark2) / 2
E OUTPUT Average
Line B — An average can have decimal places, so the variable that stores the result must be REAL, not INTEGER. It should be DECLARE Average : REAL.
Question 2
A Total ← 0
B FOR Item ← 1 TO 3
C INPUT Price
D Total ← Total + Item
E NEXT Item
F OUTPUT Total
Line D — The process is to add up the prices that were input. Item is only the loop counter. The line should be Total ← Total + Price.
Question 3
A DECLARE Name : STRING
B DECLARE Price : REAL
C DECLARE Quantity : STRING
D INPUT Quantity
Line C — A quantity is a whole number that will be used in calculations, so it should be INTEGER, not STRING. It should be DECLARE Quantity : INTEGER.
Question 4
A // Read marks of 10 students
B FOR Student ← 1 TO 9
C INPUT Mark
D OUTPUT Mark
E NEXT Student
Line B — The repeat is known to be 10 students, so the loop must run 10 times. TO 9 gives only 9 repeats. It should be FOR Student ← 1 TO 10.
Question 5
A INPUT Number
B WHILE Number <> 0 DO
C OUTPUT Number * 2
D Number ← Number * 2
E ENDWHILE
Line D — The number of repeats is unknown and ends when 0 is entered, so a new value must be input inside the loop. Changing Number by calculation never reaches 0, so the loop never ends. It should be INPUT Number.

Student with a class code? Join your class →