← IGCSE Computer Science Paper 2

The purpose of an algorithm

What the whole algorithm achieves, stated in one sentence, such as 'finds the largest of ten numbers'. It is not a line-by-line description. Check the OUTPUT and identifier names for clues.

Understanding The purpose of an algorithm in IGCSE Computer Science Paper 2

What it does: The OUTPUT of PassCount tells you the algorithm counts passes, so you begin your purpose statement from what is output. The names TotalCost and Price suggest the algorithm adds up prices to find a total cost, which helps you state the purpose. A purpose is a one-sentence summary of the overall result. Line-by-line detail earns no marks for the purpose. Meaningful identifier names are clues. Highest and Score suggest finding the highest score. The output symbol and the wording in the symbols reveal what the flowchart achieves. Counting lines does not. A better purpose is 'finds the smallest of the numbers entered', based on the OUTPUT and names like Min.

Common mistakes: The purpose is to find the total of ten numbers. The OUTPUT is Total, so each Num must be added to Total. It should be Total ← Total + Num. Without this, Total just holds the last number. The purpose is to count passes, so the counter Passes must start at 0. Starting at 10 makes the OUTPUT wrong. It should be Passes ← 0.

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 a statement of the PURPOSE of an algorithm?
Finds the largest of ten numbersSets Max to 0, then loops 10 times and compares each number
Matches
Purpose: Sets Total to 0, then adds each Mark to Total in a loop.
↓
This is a line-by-line description of the steps, not the purpose. It does not say what the whole algorithm achieves.
Applying
Meanings
Term
purpose
Meaning
What the whole algorithm achieves, stated in one sentence, such as 'finds the largest of ten numbers'. It is not a line-by-line description. Check the OUTPUT and identifier names for clues.
Practice
// Purpose: finds the largest of ten numbers
Testing
Gaps
IF Number Largest THEN Largest ← Number
Check Answer
Spots
3 INPUT Num
4 Total ← Num

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

The 'Hippopotamus' badge — Savannah Titan, 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 a statement of the PURPOSE of an algorithm?
A. Finds the largest of ten numbers ✓
B. Sets Max to 0, then loops 10 times and compares each number
The purpose says what the whole algorithm achieves in one sentence. The second option describes the lines one by one, which is not the purpose.
2. An exam asks: 'State the purpose of the algorithm.' Which answer is better?
A. Line 1 declares Total, line 2 sets it to 0, line 3 starts a FOR loop
B. Calculates the average of five test marks ✓
A purpose is a one-sentence summary of the overall result. Line-by-line detail earns no marks for the purpose.
3. Where is the best place to look first for clues about what an algorithm does?
A. The OUTPUT statement at the end ✓
B. The comment on the first line only
The OUTPUT shows what the algorithm produces, which usually reveals its purpose. Comments may be missing or misleading.
4. The algorithm ends with OUTPUT "Total cost is ", TotalCost. What is the most likely purpose?
A. Calculates and displays a total cost ✓
B. Counts how many times a loop runs
The OUTPUT text and the identifier TotalCost both point to a total cost being calculated.
5. An algorithm uses the identifiers Highest, Score and Count. What do these names suggest?
A. Identifier names never give any clues
B. It probably finds the highest score ✓
Meaningful identifier names are clues. Highest and Score suggest finding the highest score.

Match the Pairs

Max ← Number[1] FOR Index ← 2 TO 10 IF Number[Index] > Max THEN Max ← Number[Index] NEXT Index OUTPUT Max → Purpose: finds the largest of ten numbers stored in an array.
Total ← 0 FOR Count ← 1 TO 5 INPUT Mark Total ← Total + Mark NEXT Count OUTPUT Total / 5 → Purpose: calculates the average of five marks entered by the user.
Start from the OUTPUT: the value that is output shows what the algorithm is trying to achieve. → OUTPUT PassCount
Clues in identifier names: meaningful names hint at the purpose of an algorithm. → TotalCost ← TotalCost + Price
Purpose: Sets Total to 0, then adds each Mark to Total in a loop. → This is a line-by-line description of the steps, not the purpose. It does not say what the whole algorithm achieves.
Purpose: Uses a FOR loop and an IF statement. → This only names the programming constructs used. It does not say what the algorithm achieves, and it ignores the OUTPUT and identifier names.

Key Term

purpose
What the whole algorithm achieves, stated in one sentence, such as 'finds the largest of ten numbers'. It is not a line-by-line description. Check the OUTPUT and identifier names for clues.

Fill in the Blanks

1. // Purpose: finds the largest number IF Number > Largest THEN Largest ← Number
Hint: Type the relational operator that makes the variable keep the biggest value seen so far.
2. Total ← Total + Mark Average ← Total / 5 OUTPUT "Average mark: ", Average
Hint: Start from the end of the algorithm. Type the keyword that shows the final result to the user.
3. IF Age >= 18 THEN AdultCount ← AdultCount + 1 ENDIF
Hint: Type the variable being updated. Its name hints at what the algorithm is counting.
4. Process: Remainder ← Number MOD 2 Decision: Remainder = 0? Output: "Even"
Hint: This flowchart tests whether a number is even. Type the operator that gives the remainder after division.
5. FOR Count ← 1 TO 10 INPUT Number Total ← Total + Number
Hint: The whole purpose is to add up ten numbers. Type the keyword that sets the loop's upper limit.

Spot the Error

Question 1
A Total ← 0
B FOR Count ← 1 TO 10
C INPUT Num
D Total ← Num
E NEXT Count
F OUTPUT Total
Line D — The purpose is to find the total of ten numbers. The OUTPUT is Total, so each Num must be added to Total. It should be Total ← Total + Num. Without this, Total just holds the last number.
Question 2
A Passes ← 10
B INPUT Mark
C IF Mark >= 50 THEN
D Passes ← Passes + 1
E ENDIF
F OUTPUT Passes
Line A — The purpose is to count passes, so the counter Passes must start at 0. Starting at 10 makes the OUTPUT wrong. It should be Passes ← 0.
Question 3
A INPUT Mark1
B INPUT Mark2
C Average ← Mark1 + Mark2 / 2
D OUTPUT Average
Line C — The identifier name and the OUTPUT show the purpose is to find the average of two marks. Without brackets only Mark2 is divided by 2. It should be Average ← (Mark1 + Mark2) / 2.
Question 4
A INPUT Length
B INPUT Height
C Area ← Length * Width
D OUTPUT Area
Line B — The OUTPUT is Area and the calculation uses Length and Width, so the purpose is to find the area of a rectangle. Width is never given a value because Height is input instead. It should be INPUT Width.
Question 5
A INPUT Price
B Discount ← Price + 0.1
C NewPrice ← Price - Discount
D OUTPUT NewPrice
Line B — Start from the OUTPUT: NewPrice is the price after a 10% discount. Discount must be 10% of Price, so it should be Discount ← Price * 0.1, not Price + 0.1.

Student with a class code? Join your class →