Computer Science (0478) · Oct/Nov 2025 · Question paper 21

Cambridge Computer Science (0478) question paper for paper 21, Oct/Nov 2025 — 0478/21/O/N/25, file 0478_w25_qp_21.pdf.

Advertisement
Loading the paper…
Text of this paper

DFD

* 0000800000001 *

,

www.dynamicpapers.com

,

Cambridge IGCSE™
¬WŠ. 4mHuOªEŠ`|6€W
¬j™|X¥ˆpS„nPQ>Št‚
¥e••5Ueu5E5 E• ueU

* 5 0 0 9 5 4 1 4 9 1 *

COMPUTER SCIENCE
Paper 2 Algorithms, Programming and Logic

0478/21
October/November 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 20 pages. Any blank pages are indicated.
DC (WW/CB) 341856/2
© UCLES 2025

[Turn over

2

Four descriptions of structured query language (SQL) keywords and five SQL keywords are
given.
Draw one line from each description to its matching keyword.
Not all SQL keywords will be used.
SQL keywords

identifies the database table

ORDER BY
DO NOT WRITE IN THIS MARGIN

Description

COUNT
sets the condition
WHERE
sorts the results

SUM

returns the number of records

FROM
[4]

2

Identify three different types of test data that can be used to test a program.
1
2
3
[3]

3

Tick (✓) one box to identify the operator that returns the quotient of a calculation with the fractional
part discarded.
A

/

B

DIV

C

^

D

MOD

© UCLES 2025

DO NOT WRITE IN THIS MARGIN

1

,

[1]

ĬÕĊ®Ġ´íÈõÏĪÅĊÝú¸þ×
ĬêěûÕġĄĚìíùđĨëî²üĂ
ĥõąĕõµĥĕąąĥÅÅÕĥµąÕ

0478/21/O/N/25

DO NOT WRITE IN THIS MARGIN

,

DO NOT WRITE IN THIS MARGIN

www.dynamicpapers.com

DO NOT WRITE IN THIS MARGIN

DFD

* 0000800000002 *

DFD

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

* 0000800000003 *

www.dynamicpapers.com
3

,

4

,

(a) A restaurant offers a fixed priced menu. A meal for an adult costs $9.99 and a meal for a child
costs $6.99.
If there are 6 or more people at a table, a 15% discount is applied to the total cost of the
order.
Write an algorithm in pseudocode to:

•
•
•

input the number of adults and the number of children at a table
calculate the total cost of the order with the discount, if this applies
output the final cost of the order.

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

[5]
(b) The final cost of the order after the discount may have more than 2 decimal places.
Write a pseudocode statement to set the final cost of the order to 2 decimal places.
You do not need to rewrite the whole algorithm.

DO NOT WRITE IN THIS MARGIN

[2]

© UCLES 2025

Ĭ×Ċ®Ġ´íÈõÏĪÅĊÝü¸þ×
ĬêĜüÍħĀĪÍċĈØ´Óê²ČĂ
ĥõõÕµÕąõĕõµÅŵąõĕÕ

0478/21/O/N/25

[Turn over

4

,

,

(c) The restaurant offers a discount on a meal if the person ordering is either a student or is 65
years or older. The discount (X = 1) can only be given if the amount of the order is $20.00 or
over.
rule A
rule B
rule C
(i)

a student

0

not a student

1

under 65 years old

0

65 years or older

1

under $20.00

0

$20.00 or over

1

Write the logic expression for this problem.
[2]

(ii)

Draw a logic circuit for this logic expression.

DO NOT WRITE IN THIS MARGIN

www.dynamicpapers.com

DO NOT WRITE IN THIS MARGIN

DFD

* 0000800000004 *

A

B

X

C
[3]
(d) Draw the NAND logic gate symbol and complete the truth table for it.
Truth table:
A

B

0

0

0

1

1

0

1

1

X

[2]
© UCLES 2025

ĬÕĊ®Ġ´íÈõÏĪÅĊßú¸Ā×
ĬêĜùÍĝîğêąÿÏĒïČâôĂ
ĥÅåÕõÕąÕõÕÅÅąµåõąÕ

0478/21/O/N/25

DO NOT WRITE IN THIS MARGIN

NAND logic gate symbol:

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

Each logic gate must have a maximum of two inputs.
Do not simplify this logic expression.

DFD

www.dynamicpapers.com
5

,

5

,

A hotel booking system is an example of a computer system that is made up of sub-systems.
The booking system:

•
•

allows the user to select the room type and the number of nights required
displays the types of rooms available to the user as pictures or as a list.

Complete the structure diagram for the given parts of the hotel booking system.
Hotel booking system

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

* 0000800000005 *

[4]

© UCLES 2025

Ĭ×Ċ®Ġ´íÈõÏĪÅĊßü¸Ā×
ĬêěúÕīòďÏóòĚÆćÐâĄĂ
ĥÅÕĕµµĥµĥåĕÅąÕŵĕÕ

0478/21/O/N/25

[Turn over

www.dynamicpapers.com
6

,

6

,

A check digit is one method to validate a 5-digit number.
The check digit for a 5-digit number is calculated as follows:

•
•
•
•

Each digit is multiplied by its position (the first digit on the left is in position 1).
The result of each multiplication is totalled.
MOD(Total, 11) is used to calculate the check digit.
If the result of the MOD function is 10, the check digit is ‘X’.

DO NOT WRITE IN THIS MARGIN

DFD

* 0000800000006 *

The calculation of the check digit for the 5-digit number 30475 is as follows:
Multiply each digit by its position and total the results:
(3 * 1) + (0 * 2) + (4 * 3) + (7 * 4) + (5 * 5) = 68
Calculate the check digit with MOD(Total, 11)
MOD(68, 11) = 2

DO NOT WRITE IN THIS MARGIN

For example:

DECLARE Total : INTEGER
DECLARE Digit : INTEGER
DECLARE CheckDigit : CHAR
0
Total
1 TO 10
FOR Count
OUTPUT "Please enter digit ", Count
INPUT Digit
Total + (Digit / Count)
Total
NEXT Count
MOD(Total, 11)
CheckDigit
IF CheckDigit = 10
THEN
OUTPUT "The check digit is X"
ELSE
OUTPUT "The check digit is ", Count
ENDIF

© UCLES 2025

ĬÙĊ®Ġ´íÈõÏĪÅĊÞüµþ×
ĬêĜúÚġĚĕ×øăģæï­ĊôĂ
ĥĕõĕµĕĥĕåŵÅÅÕĥõÅÕ

0478/21/O/N/25

DO NOT WRITE IN THIS MARGIN

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16

DO NOT WRITE IN THIS MARGIN

This pseudocode algorithm should calculate and output the check digit of a 5-digit number:

DO NOT WRITE IN THIS MARGIN

The check digit for 30475 is 2

DFD

DO NOT WRITE IN THIS MARGIN

* 0000800000007 *

www.dynamicpapers.com
7

,

,

(a) Identify the line numbers of the four 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

DO NOT WRITE IN THIS MARGIN

Error 4 line number
Correction

[4]
(b) Explain how you could modify the pseudocode to validate that each input is a single digit.
Any code must be fully explained.

DO NOT WRITE IN THIS MARGIN

[3]
(c) The 5-digit number needs to be entered as a single input.
Describe one verification method that could be applied to the input of the 5-digit number.

DO NOT WRITE IN THIS MARGIN

[2]

© UCLES 2025

ĬÛĊ®Ġ´íÈõÏĪÅĊÞúµþ×
ĬêěùÒħĖĥâĂîæòćĩĊĄĂ
ĥĕąÕõõąõµµĥÅŵąµÕÕ

0478/21/O/N/25

[Turn over

www.dynamicpapers.com
8

,

The flowchart represents an algorithm.
START

0

DO NOT WRITE IN THIS MARGIN

Count

INPUT Number

Value

Count * Number

IS Value <=
100 ?

Count

Yes

No
Count - 1

DO NOT WRITE IN THIS MARGIN

Count

OUTPUT Count

STOP

© UCLES 2025

ĬÙĊ®Ġ´íÈõÏĪÅĊàüµĀ×
ĬêěüÒĝĨĤÕĀõÝÔëËĚüĂ
ĥåÕÕµõąÕÕĕĕÅąµåµÅÕ

Count + 1

DO NOT WRITE IN THIS MARGIN

7



0478/21/O/N/25

DO NOT WRITE IN THIS MARGIN

,

DO NOT WRITE IN THIS MARGIN

DFD

* 0000800000008 *

9

,



,

(a) Complete the tables, using the flowchart, for the given data:
Input data: 20
Count

Number

Value

Output

Number

Value

Output

Input data: 110
Count

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

www.dynamicpapers.com

DFD

* 0000800000009 *

[4]
© UCLES 2025

ĬÛĊ®Ġ´íÈõÏĪÅĊàúµĀ×
ĬêĜûÚīĬĔäúČĬĈÓďĚČĂ
ĥååĕõĕĥµÅĥÅÅąÕÅõÕÕ

0478/21/O/N/25

[Turn over

www.dynamicpapers.com
10

,

,

(b) State the purpose of the algorithm on page 8. A copy of the algorithm is provided for you on
page 11.

[1]
(c) State a suitable data type for the variable Count

DO NOT WRITE IN THIS MARGIN

DFD

* 0000800000010 *

(d) Write the algorithm in pseudocode. A copy of the algorithm is provided for you on page 11.

DO NOT WRITE IN THIS MARGIN

[1]

© UCLES 2025

ĬÙĊ®Ġ´íÈõÏĪÅĊÝü·þ×
ĬêĚüÛğĠöÛćîć°éßâĄĂ
ĥõµĕµõåÕõåĕąąĕåµõÕ

0478/21/O/N/25

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

[4]

DO NOT WRITE IN THIS MARGIN

DFD

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

* 0000800000011 *

www.dynamicpapers.com
11

,

,

START

Count

0

INPUT Number

Value

Count * Number

IS Value <=
100 ?

Count

Yes

Count + 1

No
Count

Count - 1

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

OUTPUT Count

STOP

© UCLES 2025

ĬÛĊ®Ġ´íÈõÏĪÅĊÝú·þ×
ĬêęûÓĩĤĆÞñăÂĬÑûâôĂ
ĥõÅÕõĕŵĥÕÅąąõÅõĥÕ

0478/21/O/N/25

[Turn over

12

,

8

,

A school has set up a database table SchoolTrip to record details of students that will go on a
school trip.
StudentID

StudentName

ParentName

Permission

DateReceived

STU147

Amir

Mr Akar

True

03/03/2025

STU348

Filip

Mrs Johnson

True

04/03/2025

STU274

Matthew

Mr Smith

False

STU873

Jafar

Mr Al-Saigh

True

21/03/2025

STU221

Hussein

Mr Alkasab

True

28/02/2025

STU553

Julie

Mrs Jones

True

25/02/2025

STU213

Julie

Mr Smith

False

(a) State the reason why ParentName is not appropriate as the primary key.
[1]

DO NOT WRITE IN THIS MARGIN

www.dynamicpapers.com

DO NOT WRITE IN THIS MARGIN

DFD

* 0000800000012 *

[1]
(c) The database only uses these data types:

•
•
•
•
•
•

text
character
Boolean
integer
real
date/time.

Field

DO NOT WRITE IN THIS MARGIN

Complete the table to show the most appropriate data type for each field.
Each data type must be different.

DO NOT WRITE IN THIS MARGIN

(b) Give the name of the field that should be the primary key.

Data type

ParentName
Permission
DateReceived

(d) Complete the structured query language (SQL) statement to display only the names of the
students who do not have permission to go on the trip.
SELECT
FROM
WHERE
[2]
ĬÙĊ®Ġ´íÈõÏĪÅĊßü·Ā×

© UCLES 2025

ĬêęúÓģĒăÙïČÉÊíÙ²ČĂ
ĥÅĕÕµĕÅĕąõµąÅõĥõõÕ

0478/21/O/N/25

DO NOT WRITE IN THIS MARGIN

[2]

DO NOT WRITE IN THIS MARGIN

www.dynamicpapers.com

DFD

* 0000800000013 *

13

,

9

,

A school stores all the students’ attendance data in a file called Attendance.txt
Write an algorithm in pseudocode to read a line of text from the file and store this line in the
variable StudentAttendance

DO NOT WRITE IN THIS MARGIN

[4]
10 The variables Seconds and Minutes are used in a program. Seconds holds the number of
seconds as a whole number and Minutes holds the number of minutes as a whole number.

DO NOT WRITE IN THIS MARGIN

(a) Write pseudocode statements to declare the variables Seconds and Minutes

[1]
(b) The procedure Time(TotalSeconds) takes the number of seconds as a parameter. The
procedure converts the value held in the parameter into minutes and seconds and outputs
the result.

DO NOT WRITE IN THIS MARGIN

Write this procedure in pseudocode.

DO NOT WRITE IN THIS MARGIN

[4]

© UCLES 2025

ĬÛĊ®Ġ´íÈõÏĪÅĊßú·Ā×
ĬêĚùÛĥĎóàĉõĀĎąý²üĂ
ĥÅĥĕõõåõĕąĥąÅĕąµĥÕ

0478/21/O/N/25

[Turn over

The scores for each competitor in an archery competition are recorded.
The one-dimensional (1D) array CompetitorName[] is used to store the names of the
competitors.
The maximum number of competitors is 30.
There are 10 rounds in the competition with a maximum score of 30 per round.
The two-dimensional (2D) array CompetitorScore[] stores the score in each of the 10 rounds
for each competitor.
The first index of the array CompetitorScore[] is the same as the index of the competitor in
CompetitorName[]
After the 10 rounds have been completed, the highest score and the lowest score for each
competitor are discarded.
The overall score for each competitor is the total of the remaining 8 scores (after discarding the
highest and lowest scores) .
A competitor with an overall score of 210 or more moves onto the next competition. A competitor
with an overall score between 180 and 209 inclusive becomes a reserve competitor. A competitor
with an overall score below 180 does not qualify.
Write a program that meets the following requirements:

•
•
•
•
•

inputs the total score (out of 30) for each competitor in each round
validates each input is between 0 and 30 inclusive
calculates the overall score for each competitor discarding the highest and lowest scores
outputs the name of each competitor and if they move onto the next competition, are a
reserve or do not qualify
calculates and outputs the number of competitors who:
◦
have qualified for the next competition
◦
are reserve competitors
◦
do not qualify.

You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays or variables; assume that this has already been done.
All inputs and outputs must contain suitable messages.

DO NOT WRITE IN THIS MARGIN

11

,

DO NOT WRITE IN THIS MARGIN

14

,

DO NOT WRITE IN THIS MARGIN

www.dynamicpapers.com

DO NOT WRITE IN THIS MARGIN

DFD

* 0000800000014 *

© UCLES 2025

ĬÕĊ®Ġ´íÈõÏĪÅĊàù¶Ă×
ĬêęûÚīġċÎÿòã²ÐĉĂôĂ
ĥĥĥÕµĕĥÕõĕĥÅąÕåõµÕ

0478/21/O/N/25

DO NOT WRITE IN THIS MARGIN

DFD

DO NOT WRITE IN THIS MARGIN

* 0000800000015 *

www.dynamicpapers.com
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/21/O/N/25

[Turn over

www.dynamicpapers.com
16

,

,

DO NOT WRITE IN THIS MARGIN

DFD

* 0000800000016 *

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

© UCLES 2025

ĬÕĊ®Ġ´íÈõÏĪÅĊÞù¶Ą×
ĬêĚùÒħďîÐ÷ĈĝÈČïĒüĂ
ĥÕÅĕµõąĕąÅÅÅŵĥµµÕ

0478/21/O/N/25

DO NOT WRITE IN THIS MARGIN

DFD

DO NOT WRITE IN THIS MARGIN

* 0000800000017 *

www.dynamicpapers.com
17

,

,

[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/21/O/N/25

www.dynamicpapers.com
18

,



,

© UCLES 2025

ĬÕĊ®Ġ´íÈõÏĪÅĊßù¸Ă×
ĬêěùÛĥėĬÒðÿÇìĊěêĄĂ
ĥąåÕµõåĕåõÅąÅĕĥµąÕ

0478/21/O/N/25

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

BLANK PAGE

DO NOT WRITE IN THIS MARGIN

DFD

* 0000800000018 *

DFD

www.dynamicpapers.com
19

,



,

BLANK PAGE

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

* 0000800000019 *

© UCLES 2025

Ĭ×Ċ®Ġ´íÈõÏĪÅĊßû¸Ă×
ĬêĜúÓģěĜçĊòĂðò¿êôĂ
ĥąÕĕõĕÅõµąĕąÅõąõĕÕ

0478/21/O/N/25

www.dynamicpapers.com
20

,

,

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/21/O/N/25

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

BLANK PAGE

DO NOT WRITE IN THIS MARGIN

DFD

* 0000800000020 *

Advertisement