Computer Science (0478) · May/June 2025 · Question paper 22
Cambridge Computer Science (0478) question paper for paper 22, May/June 2025 — 0478/22/M/J/25, file 0478_s25_qp_22.pdf.
Text of this paper
* 0000800000001 *
,
,
Cambridge IGCSE™
¬O. 4mHuOªE^y6W
¬jrV©ua U¤5j
¥EUuU¥u¥¥ EUE55U
* 7 6 9 2 2 7 4 3 1 0 *
COMPUTER SCIENCE
Paper 2 Algorithms, Programming and Logic
0478/22
May/June 2025
1 hour 45 minutes
You must answer on the question paper.
No additional materials are needed.
INSTRUCTIONS
●
Answer all questions.
●
Use a black or dark blue pen. You may use an HB pencil for any diagrams or graphs.
●
Write your name, centre number and candidate number in the boxes at the top of the page.
●
Write your answer to each question in the space provided.
●
Do not use an erasable pen or correction fluid.
●
Do not write on any bar codes.
●
Calculators must not be used in this paper.
INFORMATION
●
The total mark for this paper is 75.
●
The number of marks for each question or part question is shown in brackets [ ].
●
No marks will be awarded for using brand names of software packages or hardware.
This document has 16 pages. Any blank pages are indicated.
DC (WW/JG) 341855/2
© UCLES 2025
[Turn over
2
,
1
,
Tick (✓) one box to complete the description of abstraction.
Abstraction is part of the analysis stage of the development life cycle. Abstraction means
2
A
testing the solution to the problem.
B
writing a program using program code.
C
defining the sub-systems that make up the problem.
D
removing details from the problem that are not relevant.
[1]
A fence measuring 2 metres in height and 20 metres in length needs painting. The area of the
fence needs to be calculated so that enough paint for the job is purchased.
After the task is decomposed, there are three component parts: input, process and output.
Three component parts and four example descriptions are shown.
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000002 *
Component part
DO NOT WRITE IN THIS MARGIN
Draw one line from each component part to the most appropriate relevant description.
Not all descriptions will be used.
Description
the height of the fence
the length of the fence
process
The amount of paint required is
40 square metres.
output
input
The area of fence is calculated as
40 square metres.
[3]
3
A range check is used to validate that the input temperature is an integer between –100 and 0,
inclusive.
DO NOT WRITE IN THIS MARGIN
the colour of the paint
Normal test data
Abnormal test data
Extreme test data
Boundary test data
[4]
ĬÍĊ®Ġ´íÈõÏĪÅĊßû¸þ×
© UCLES 2025
Ĭêėñ×ĝñüÚ÷óðĝĚąĒČĂ
ĥĕÅĕµµåõÅåµÅÅĕåõĕÕ
0478/22/M/J/25
DO NOT WRITE IN THIS MARGIN
Suggest suitable normal, abnormal, extreme and boundary test data to test if this validation check
is working correctly.
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000003 *
3
,
4
,
(a) State one reason for using a verification check when inputting data.
[1]
(b) Write the pseudocode for an algorithm to perform a double entry verification check, using the
following criteria:
•
•
•
Input 10 numbers and store them in the array Numbers[]
Input the same 10 numbers again; as each number is input, compare it with its
corresponding number in the array Numbers[]
◦
if the numbers match, move on to the next number
◦
if the numbers do not match, display both numbers and ask for the number to be
re-entered
◦
store the re-entered number in the corresponding array location and move on to the
next number.
When all the numbers have been checked, display a message to say the check has
been completed.
DO NOT WRITE IN THIS MARGIN
You do not need to declare any arrays or variables for this algorithm.
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
[6]
© UCLES 2025
ĬÏĊ®Ġ´íÈõÏĪÅĊßù¸þ×
ĬêĘòÏīíČßāþ¹¹ĢÑĒüĂ
ĥĕµÕõÕÅĕÕÕĥÅÅõŵąÕ
0478/22/M/J/25
[Turn over
•
•
•
•
•
at the start, the following data is entered:
◦
name of person
◦
height of person in cm
the data is stored in the relevant arrays
the heights of the people are totalled
the shortest person is found
at the end, the following is output:
◦
name of shortest person
◦
height of shortest person
◦
average height of all 500 people.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
DECLARE Names : ARRAY[1:500] OF REAL
DECLARE Heights : ARRAY[1:500] OF REAL
DECLARE Shortest : REAL
DECLARE Total : REAL
DECLARE Counter : INTEGER
DECLARE Index : INTEGER
500
Shortest
0
Index
100
Total
1 TO 500
FOR Counter
INPUT Names[Index]
INPUT Heights[Counter]
Counter + Heights[Counter]
Total
IF Heights[Counter] < Shortest
THEN
Heights[Counter]
Shortest
Counter
Index
ENDIF
NEXT Counter
OUTPUT "The shortest height is ", Heights
OUTPUT "The shortest person is ", Names[Index]
OUTPUT "The average height is ", Total / 500
© UCLES 2025
ĬÍĊ®Ġ´íÈõÏĪÅĊÝû¸Ā×
ĬêĘóÏġÿýÜÿą²ě¾óĂĄĂ
ĥåĥÕµÕŵµõĕÅąõĥµĕÕ
0478/22/M/J/25
DO NOT WRITE IN THIS MARGIN
The algorithm performs as follows:
DO NOT WRITE IN THIS MARGIN
This pseudocode algorithm should allow 500 names of people and their heights to be entered and
stored in two one-dimensional (1D) arrays. The name of a person and the height of that person
are in the same index in both the Names[] and the Heights[] arrays.
DO NOT WRITE IN THIS MARGIN
5
,
DO NOT WRITE IN THIS MARGIN
4
,
DO NOT WRITE IN THIS MARGIN
* 0000800000004 *
DO NOT WRITE IN THIS MARGIN
* 0000800000005 *
5
,
,
(a) Identify the line numbers of five errors in the pseudocode and suggest a correction for each
error.
Error 1 line number
Correction
DO NOT WRITE IN THIS MARGIN
Error 2 line number
Correction
Error 3 line number
Correction
Error 4 line number
DO NOT WRITE IN THIS MARGIN
Correction
Error 5 line number
Correction
[5]
(b) Write the pseudocode statement that will output the average height rounded to one decimal
place.
DO NOT WRITE IN THIS MARGIN
[2]
(c) Explain how you could change the corrected algorithm so that it will also:
•
•
find the height of the tallest person.
output the height of the tallest person at the end of the algorithm.
Any program statements used must be fully explained.
DO NOT WRITE IN THIS MARGIN
[4]
ĬÏĊ®Ġ´íÈõÏĪÅĊÝù¸Ā×
Ĭêėô×ħăíÝùü÷¿¶çĂôĂ
0478/22/M/J/25
[Turn
over
ĥåĕĕõµåÕåąÅÅąĕąõąÕ
© UCLES 2025
This pseudocode is an algorithm.
© UCLES 2025
ĬÑĊ®Ġ´íÈõÏĪÅĊàùµþ×
ĬêĘôÜĝī÷åîĉþß¾ÆêĄĂ
ĥõµĕõĕåõĥĥĥÅÅĕåµÕÕ
0478/22/M/J/25
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DECLARE Word : STRING
DECLARE V1 : INTEGER
DECLARE V2 : INTEGER
DECLARE Number : INTEGER
DECLARE Index : INTEGER
DECLARE L1 : CHAR
DECLARE L2 : CHAR
DECLARE Continue : BOOLEAN
INPUT Number
1 TO Number
FOR Index
INPUT Word
TRUE
Continue
1
V1
LENGTH(Word)
V2
WHILE Continue = TRUE AND V1 < V2 DO
SUBSTRING(Word, V1, 1)
L1
SUBSTRING(Word, V2, 1)
L2
IF L1 <> L2
THEN
FALSE
Continue
ELSE
V1 + 1
V1
V2 – 1
V2
ENDIF
ENDWHILE
IF Continue = TRUE
THEN
OUTPUT "Successful"
ELSE
OUTPUT "NOT successful"
ENDIF
NEXT Index
DO NOT WRITE IN THIS MARGIN
6
,
DO NOT WRITE IN THIS MARGIN
6
,
DO NOT WRITE IN THIS MARGIN
* 0000800000006 *
7
,
,
(a) Complete the trace table for the algorithm, using the input data:
2, RACECAR, TREAT
Number
Index
Word
Continue
V1
V2
L1
L2
OUTPUT
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000007 *
DO NOT WRITE IN THIS MARGIN
[6]
(b) State the purpose of the algorithm on page 6.
[1]
(c) Explain how the algorithm knows when all the letters in the word have been checked so that it
can stop checking.
DO NOT WRITE IN THIS MARGIN
[3]
ĬÓĊ®Ġ´íÈõÏĪÅĊàûµþ×
ĬêėóÔīħćÔČøËû¶ĒêôĂ
© UCLES 2025
0478/22/M/J/25
[Turn over
ĥõÅÕµõÅĕõĕµÅÅõÅõÅÕ
8
,
7
,
The flowchart shows an algorithm that is used to input 50 numbers. Each number is stored in the
variable Value when it is input. Any number input that is less than or equal to –20 or greater than
or equal to 50 is rejected and re-input. The accepted numbers are added together as they are
entered and the total and average of these numbers are output at the end of the algorithm.
(a) Complete the flowchart.
DO NOT WRITE IN THIS MARGIN
* 0000800000008 *
0
Total
0
DO NOT WRITE IN THIS MARGIN
Count
DO NOT WRITE IN THIS MARGIN
START
Yes
No
Yes
STOP
[6]
© UCLES 2025
ĬÑĊ®Ġ´íÈõÏĪÅĊÞùµĀ×
ĬêėòÔġĕĂçĆïÄÙĚ´ºČĂ
ĥÅĕÕõõŵĕµÅÅąõĥõÕÕ
0478/22/M/J/25
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
No
DO NOT WRITE IN THIS MARGIN
* 0000800000009 *
9
,
,
(b) Explain how you would alter the flowchart in 7(a) so that it will individually store each accepted
value as it is entered and then output all the numbers, one after the other, outside of the loop
that inputs values.
You may include program statements or flowchart symbols in your answer, but they must be
fully explained.
DO NOT WRITE IN THIS MARGIN
[4]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
© UCLES 2025
ĬÓĊ®Ġ´íÈõÏĪÅĊÞûµĀ×
ĬêĘñÜħęòÒôĂąýĢĨºüĂ
ĥÅĥĕµĕåÕąÅĕÅąĕąµÅÕ
0478/22/M/J/25
[Turn over
DO NOT WRITE IN THIS MARGIN
* 0000800000010 *
10
8
,
(a) Draw the symbol for an XOR logic gate and complete the truth table for it.
DO NOT WRITE IN THIS MARGIN
XOR logic gate symbol:
Truth table:
A
B
0
0
0
1
1
0
1
1
X
© UCLES 2025
ĬÑĊ®Ġ´íÈõÏĪÅĊßù·þ×
ĬêĖòÙģčĘéýøĪµĜØĂôĂ
ĥĕõĕõõĥµµąÅąąÕĥõĥÕ
0478/22/M/J/25
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
[2]
DO NOT WRITE IN THIS MARGIN
,
DO NOT WRITE IN THIS MARGIN
* 0000800000011 *
11
,
,
(b) Consider the logic rules in the following table:
Input
A
DO NOT WRITE IN THIS MARGIN
B
C
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
Description
0
operator not present
1
operator present
0
ignition key present
1
ignition key not present
0
operator code correct
1
operator code not correct
A crane is a machine with a long arm used to lift heavy objects. The crane will only move:
•
•
if the operator is present and
either the ignition key is present, or the operator code is correct.
The crane moving is represented by X = 1.
(i)
DO NOT WRITE IN THIS MARGIN
Binary value
Write the logic expression for the crane moving.
X = [2]
(ii)
Complete the truth table for the crane moving.
A
B
C
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
Working space
X
[4]
© UCLES 2025
ĬÓĊ®Ġ´íÈõÏĪÅĊßû·þ×
ĬêĕñÑĥđĨÐûĉßġĤĄĂĄĂ
ĥĕąÕµĕąÕåõĕąąµąµõÕ
0478/22/M/J/25
[Turn over
12
,
9
,
A database table, CapitalCity, stores data about capital cities from around the world.
Field
Description
Identification
a unique identifier
Name
the name of the city
Country
the name of the country in which the city is located
Continent
the name of the continent in which the city is located
Population
the number of people living in the city
Founded
the year the city was founded
AverageIncome
average income of the city’s population, in $, rounded to 2 decimal places
Subway
whether or not the city has an underground railway system
(a) Complete the table by writing one appropriate field from CapitalCity for each data type.
Each field must be different.
Field
DO NOT WRITE IN THIS MARGIN
Data type
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000012 *
Boolean
integer
real
text
SELECT
CapitalCity
WHERE = ;
[4]
© UCLES 2025
ĬÑĊ®Ġ´íÈõÏĪÅĊÝù·Ā×
ĬêĕôÑğģġëõĂèÃÀâĒüĂ
ĥåÕÕõĕąõÅÕĥąÅµåµĥÕ
0478/22/M/J/25
DO NOT WRITE IN THIS MARGIN
(b) Complete the structured query language (SQL) statement to list only the name, country and
population of all the cities in CapitalCity from the continent of Asia.
DO NOT WRITE IN THIS MARGIN
[2]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000013 *
,
© UCLES 2025
,
13
BLANK PAGE
ĬÓĊ®Ġ´íÈõÏĪÅĊÝû·Ā×
ĬêĖóÙĩğđÎăïġė¸öĒČĂ
ĥååĕµõĥĕÕåµąÅÕÅõõÕ
0478/22/M/J/25
[Turn over
14
,
,
10 A program is required to allow students to calculate the volume of a number of standard
three-dimensional shapes. It will use functions to allow other shapes to be added in the future.
Cuboid
height
volume = base × depth × height
DO NOT WRITE IN THIS MARGIN
* 0000800000014 *
base
Triangular prism
volume = 1 2 × base × depth × height
height
depth
DO NOT WRITE IN THIS MARGIN
depth
Sphere
volume = 4 3 × Pi × radius × radius × radius
radius
Pi is a constant with value 3.142
DO NOT WRITE IN THIS MARGIN
base
•
•
•
•
Output a menu to ask the user for an input to indicate the shape for which a volume needs to
be calculated, from the three shapes given or if they want to stop the program. The program
must validate the input.
Input the data needed to calculate the volume of the chosen shape, based on the given
formulae.
Create one function for each shape to calculate and return the volume using the given
formulae. Each function uses the input data as parameters.
Output the volume in the main program, rounded to two decimal places.
The program continues until the user inputs the stop option from the menu.
DO NOT WRITE IN THIS MARGIN
Write a program that meets the following requirements:
All variables and constants used must be declared for this algorithm.
All inputs and outputs must contain suitable messages.
ĬÍĊ®Ġ´íÈõÏĪÅĊÞü¶Ă×
© UCLES 2025
ĬêĕñÜħĔĩàąü¾»ĝòâĄĂ
ĥąåÕõĕåµµµµÅąĕĥµåÕ
0478/22/M/J/25
DO NOT WRITE IN THIS MARGIN
You must use pseudocode or program code and add comments to explain how your code works.
DO NOT WRITE IN THIS MARGIN
* 0000800000015 *
15
,
,
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
© UCLES 2025
ĬÏĊ®Ġ´íÈõÏĪÅĊÞú¶Ă×
ĬêĖòÔġĐęÙóąċğĕæâôĂ
ĥąÕĕµõÅÕåÅĥÅąõąõµÕ
0478/22/M/J/25
[Turn over
16
,
,
DO NOT WRITE IN THIS MARGIN
* 0000800000016 *
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.
© UCLES 2025
ĬÍĊ®Ġ´íÈõÏĪÅĊàü¶Ą×
ĬêĖóÔīĞĐÞíþĄ½¹Ĉ²ČĂ
ĥµąĕõõÅõÅĥĕÅÅõåõåÕ
0478/22/M/J/25
DO NOT WRITE IN THIS MARGIN
[15]