IGCSE · Computer Science 0478 · Topic

Algorithms & Programming: IGCSE Computer Science questions and answers

10 free IGCSE Computer Science Algorithms & Programming questions written in the style of Cambridge Computer Science papers, each with its answer and mark scheme.

This topic covers Program development life cycle, Algorithms & trace tables, Validation, verification & test data, Programming & scenario questions, Arrays, File handling. Work through the questions below, then generate a full Algorithms & Programming paper with a fresh set every time.

Generate a full Algorithms & Programming paper →

Algorithms & programming sub-topics

Algorithms & programming practice questions

Question 1Structured · 6 marks

The algorithm below is written in pseudocode.

(a)

Complete the trace table for the input data: 23, 9, 24, 4, 14

XNumMaxCountOUTPUT
Table 1.1
[4]
(b)

State the purpose of this algorithm.

[2]
Show answers and mark scheme
PartAnswer and marking pointsMarks
(a)Output: 24, 3
X and Num columns correct B1
Max column correct B1
Count column correct B1
Output 24, 3 B1
4
(b)Finds the largest of five numbers and counts how many are even
Finds the maximum B1
Counts the even numbers B1
2
Question 2Structured · 5 marks

Write an algorithm in pseudocode to input the temperatures (°C) recorded at a weather station on 40 days, and output the number of temperatures below 0 and the average temperature.

[5]
Show answers and mark scheme
PartAnswer and marking pointsMarks
Initialise Total and Count to 0; FOR 1 TO 40; INPUT value; add to Total; IF condition THEN Count ← Count + 1; NEXT; OUTPUT Count and Total / 40
Total and Count initialised to 0 B1
Loop that runs 40 times B1
INPUT inside the loop and value added to Total B1
IF Temp < 0 (or equivalent; not <=) THEN Count ← Count + 1 B1
Average = Total / 40 calculated after the loop and both outputs B1
5
Question 3Structured · 6 marks

A program needs to store data permanently in a text file called Stock.txt.

(a)

Explain why data is stored in a file rather than only in variables.

[2]
(b)

Write pseudocode to input 5 lines of text from the user and write them to the file Stock.txt, then close the file.

[4]
Show answers and mark scheme
PartAnswer and marking pointsMarks
(a)Data in variables is lost when the program ends / computer is switched off; a file stores it permanently so it can be used again / by another program
Variables / RAM lose data when the program closes B1
File stores data permanently for later use / to share B1
2
(b)OPENFILE "Stock.txt" FOR WRITE; FOR Count ← 1 TO 5; INPUT Line; WRITEFILE "Stock.txt", Line; NEXT Count; CLOSEFILE "Stock.txt"
OPENFILE "Stock.txt" FOR WRITE B1
Loop 5 times with INPUT inside B1
WRITEFILE "Stock.txt", Line inside the loop B1
CLOSEFILE "Stock.txt" after the loop B1
4
Question 4Structured · 5 marks

A program uses a bubble sort to put the array Values[1:6] into ascending order. Before sorting, the array contains:
3 12 15 9 7 18

(a)

Write the contents of the array after the first pass of the bubble sort.

[2]
(b)

State the number of swaps made in the first pass.

[1]
(c)

Explain how the algorithm knows the array is sorted, so that it can stop early.

[2]
Show answers and mark scheme
PartAnswer and marking pointsMarks
(a)3 12 9 7 15 18
3 12 9 7 15 18 B2
B1 if only one adjacent pair of values is in the wrong order
2
(b)2
2 B1
1
(c)A flag records whether any swap was made in a pass; if a complete pass makes no swaps the array is sorted
Uses a flag / Boolean variable set when a swap happens B1
Stops when a whole pass completes with no swaps B1
2
Question 5Structured · 6 marks

The pseudocode function below is part of a word-game program.

(a)

State the value returned by CountChar("BANANA", 'A').

[1]
(b)

Give the identifier of one parameter and the identifier of one local variable in the function.

[2]
(c)

Explain why CountChar is written as a function rather than as a procedure.

[1]
(d)

Write a pseudocode statement that uses CountChar to output the number of times the letter E appears in the string variable Sentence.

[2]
Show answers and mark scheme
PartAnswer and marking pointsMarks
(a)3
3 B1
1
(b)parameter: Word / Letter; local variable: Count / Index
Word or Letter B1
Count or Index B1
2
(c)it returns a single value (the count) to the point where it is called
It returns a value (to the calling statement) B1
1
(d)OUTPUT CountChar(Sentence, 'E')
OUTPUT with a call to CountChar B1
Correct arguments Sentence and 'E' in the right order B1
2
Question 6Structured · 6 marks

A developer is creating a library book-loan system.

(a)

The program development life cycle has four stages. Name the four stages in order.

[2]
(b)

State one activity, or one tool used, in the analysis stage.

[1]
(c)

Decompose the system into its main sub-systems by drawing a structure diagram with a library book-loan system at the top and at least three sub-systems below it.

[3]
Show answers and mark scheme
PartAnswer and marking pointsMarks
(a)analysis, design, coding, testing
All four stages named B1
in the correct order B1
2
(b)abstraction / decomposition / identification of the problem and requirements
abstraction / decomposition / identification of the problem and requirements B1
1
(c)Top box: the system; below it, e.g. find a book, record a loan, record a return, calculate a late fine
Top-level box naming the system B1
At least three suitable sub-systems on the next level, e.g. find a book / record a loan / record a return B1
Correct hierarchical structure (lines from the top box to each sub-system) B1
3
Question 7Structured · 6 marks
(a)

Identify the most suitable validation check for a password, which must have at least 8 characters.

[1]
(b)

Identify the most suitable validation check for the age of a student, which must be from 11 to 18.

[1]
(c)

Identify the most suitable validation check for a date of birth, in the form DD/MM/YYYY.

[1]
(d)

A program accepts whole numbers from 20 to 73 inclusive. Give one example of normal, extreme and abnormal test data.

[3]
Show answers and mark scheme
PartAnswer and marking pointsMarks
(a)length check
length check B1
1
(b)range check
range check B1
1
(c)format check
format check B1
1
(d)normal: e.g. 47; extreme: 20 or 73; abnormal: e.g. 78 or "ten"
normal between 20 and 73 B1
extreme 20 or 73 B1
abnormal outside range or wrong type B1
3
Question 8Structured · 5 marks

The pseudocode below calculates the price of a cinema ticket.

(a)

State the output when the input is 80 then "G".

[1]
(b)

State the output when the input is 50 then "X".

[1]
(c)

Rewrite the CASE structure using IF statements, so that the program works in the same way.

[3]
Show answers and mark scheme
PartAnswer and marking pointsMarks
(a)68
68 B1
1
(b)50
50 B1
1
(c)IF Code = "S" THEN Discount ← 5 ELSE IF Code = "G" THEN Discount ← 15 ELSE Discount ← 0 ENDIF ENDIF
IF Code = "S" THEN Discount ← 5 B1
Nested IF / ELSE for Code = "G" giving Discount ← 15 B1
ELSE Discount ← 0 and correct ENDIFs B1
3
Question 9Structured · 4 marks

Give the value returned by each of these expressions.

ExpressionValue
75 MOD 8
UCASE("Network")
ROUND(10.236, 1)
LENGTH("Network")
Table 9.1

Complete the table.

[4]
Show answers and mark scheme
PartAnswer and marking pointsMarks
75 MOD 8 = 3; UCASE("Network") = NETWORK; ROUND(10.236, 1) = 10.2; LENGTH("Network") = 7
75 MOD 8 = 3 B1
UCASE("Network") = NETWORK B1
ROUND(10.236, 1) = 10.2 B1
LENGTH("Network") = 7 B1
4
Question 10Structured · 6 marks

A two-dimensional array Sales[1:12, 1:5] stores the daily sales for each of 12 shops on 5 days. The array has already been filled with whole numbers.

Write an algorithm in pseudocode to output the total for each row of the array, and then output the largest of these totals.

[6]
Show answers and mark scheme
PartAnswer and marking pointsMarks
Largest ← 0; FOR Row ← 1 TO 12; Total ← 0; FOR Col ← 1 TO 5; Total ← Total + Sales[Row, Col]; NEXT Col; OUTPUT Total; IF Total > Largest THEN Largest ← Total ENDIF; NEXT Row; OUTPUT Largest
Largest initialised before the outer loop (to 0 or to the first total) B1
Outer loop 1 to 12 with Total reset to 0 inside it B1
Inner loop 1 to 5 B1
Total ← Total + Sales[Row, Col] with indices in the correct order B1
OUTPUT Total after the inner loop, inside the outer loop B1
Compare and update Largest; OUTPUT Largest after both loops B1
6

Other IGCSE Computer Science topics

Frequently asked questions

What is in IGCSE Computer Science Algorithms & Programming?

In the 0478 syllabus, Algorithms & Programming covers Program development life cycle, Algorithms & trace tables, Validation, verification & test data, Programming & scenario questions, Arrays, File handling.

Where can I get Algorithms & Programming questions with mark schemes?

This page has 10 Algorithms & Programming questions with answers. For more, the free generator on mentorriyaz.in builds a new Algorithms & Programming paper with a full mark scheme each time you click.

Want a mentor, not just a paper?

Riyaz Shaikh has mentored IGCSE, IB and A Level students for 15+ years, one-on-one, online and in Mumbai. The hardest questions on this site are the ones he uses to find a student's weak points.

Meet Riyaz →

Original Cambridge-style practice questions written for mentorriyaz.in. These are not Cambridge past paper questions, and this site is not affiliated with or endorsed by Cambridge University Press & Assessment. Updated 2026-11-04. Paper generator · mentorriyaz.in