Computer Science (0478) · Feb/March 2025 · Question paper 22

Cambridge Computer Science (0478) question paper for paper 22, Feb/March 2025 — 0478/22/F/M/25, file 0478_m25_qp_22.pdf.

Advertisement
Loading the paper…
Text of this paper

* 0000800000001 *

,

,

Cambridge IGCSE™
¬OŠ. 4mHuOªEŠ^y6€W
¬`“qR©¥›^z}:`hŒŠy‚
¥¥u•5uE55EeE • UUU

* 2 5 6 1 2 6 5 1 3 6 *

COMPUTER SCIENCE
Paper 2 Algorithms, Programming and Logic

0478/22
February/March 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 (DE/SG) 341750/3
© UCLES 2025

[Turn over

1

,

Tick (✓) one box to complete this sentence.
A standard method of solution used to find a piece of data in an array is a
A

bubble sort.

B

counting routine.

C

linear search.

D

selection search.
[1]

2

Tick (✓) one box to complete this sentence.
The pseudocode to store a hotel name held in the variable Name to a text file is
A

READFILE Hotels.txt, Name

B

WRITEFILE Hotels.txt, Name

C

WRITEFILE Name, Hotels.txt

D

STOREFILE Hotels.txt, Name
[1]

3

Four development life cycle stages and five descriptions are shown.

Stage

Description

testing

identifying the problem and requirements

DO NOT WRITE IN THIS MARGIN

Draw one line from each stage to the most appropriate description.
Not all descriptions will be used.

reviewing the final solution to suggest further
developments

analysis

DO NOT WRITE IN THIS MARGIN

2
,

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

* 0000800000002 *

coding

using structure diagrams, flowcharts and pseudocode to
plan the solution

design

using a programming language to create the solution
[4]

© UCLES 2025

ĬÍĊ®Ġ´íÈõÏĪÅĊßû¸þ×
ĬàđòÓĝġíÕćûÕĘμ²ñĂ
ĥµĥĕõĕąÕąąõąąÕĥĕõÕ

0478/22/F/M/25

DO NOT WRITE IN THIS MARGIN

making sure the program code works as expected

DO NOT WRITE IN THIS MARGIN

* 0000800000003 *

3
,

4

,

(a) A presence check is a type of validation check.
State the purpose of a presence check.

[1]

DO NOT WRITE IN THIS MARGIN

(b) A value input into a computer system must be an integer.
(i)

Identify the validation check used to test whether the value input meets this requirement.
[1]

(ii)

Write the pseudocode for an algorithm to allow a number to be input into an appropriate
variable and check whether the number is an integer. If the number is an integer, it is
accepted. If the number is not an integer, an error message is output. Re-input of the
number is required until a valid number is input.

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

[5]

© UCLES 2025

ĬÏĊ®Ġ´íÈõÏĪÅĊßù¸þ×
ĬàĒñÛīĝýäñĆĔÄæĠ²āĂ
ĥµĕÕµõĥµĕõåąąµąÕĥÕ

0478/22/F/M/25

[Turn over

4
A program is written to only accept data that contains more than 9 characters. The program needs
to be tested. The table, when completed, shows appropriate test data that matches the type of test
data and the purpose of the test data.
Complete the table by inserting the missing information.
Test data

Type of test data

Purpose of test data

Boundary

to make sure that the program accepts data
that is an appropriate length
[6]

6

This pseudocode algorithm is intended to allow 1000 positive integers to be input and stored in
a one-dimensional (1D) array. The integers are added together as they are input and the highest
value is identified. At the end of the algorithm, the highest number, the total and the average of the
numbers are output.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17

DECLARE Numbers : ARRAY[1:1000] OF INTEGER
DECLARE Highest : STRING
DECLARE Count : INTEGER
DECLARE Total : INTEGER
1500
Highest
0
Total
1 TO 1000
FOR Count
INPUT Numbers[Count]
Total + Count
Total
IF Numbers[Count] > Total
THEN
Numbers[Count]
Highest
ENDIF
NEXT Count
OUTPUT "The highest number is ", Highest
OUTPUT "The total is ", Total
OUTPUT "The average is ", Average / 1000

←
←
←
←

←

(a) Identify the line numbers of five errors in the pseudocode and suggest a correction for each
error.
Error 1 line number
Correction

© UCLES 2025

ĬÍĊ®Ġ´íÈõÏĪÅĊÝû¸Ā×
ĬàĒôÛġďČ×ïýěĢĊ¾âùĂ
ĥąÅÕõõĥĕõÕÕąÅµåÕõÕ

0478/22/F/M/25

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

ABC

DO NOT WRITE IN THIS MARGIN

5

,

DO NOT WRITE IN THIS MARGIN

,

DO NOT WRITE IN THIS MARGIN

* 0000800000004 *

DO NOT WRITE IN THIS MARGIN

* 0000800000005 *

5
,

,

Error 2 line number
Correction

Error 3 line number

DO NOT WRITE IN THIS MARGIN

Correction

Error 4 line number
Correction

Error 5 line number

DO NOT WRITE IN THIS MARGIN

Correction

[5]
(b) Write the pseudocode statement to output the average of the numbers, rounded to two
decimal places.

[2]

DO NOT WRITE IN THIS MARGIN

(c) Explain how you could change the corrected algorithm so that it also finds the smallest
number that was input and outputs its value at the end.
Any code used must be fully explained.

DO NOT WRITE IN THIS MARGIN

[4]

© UCLES 2025

ĬÏĊ®Ġ´íÈõÏĪÅĊÝù¸Ā×
ĬàđóÓħēüâĉôζòĚâĉĂ
ĥąµĕµĕąõĥåąąÅÕÅĕĥÕ

0478/22/F/M/25

[Turn over

6
This flowchart represents an algorithm.
START

OUTPUT
"Continue?"

INPUT Answer

No

Yes

IS Answer =
'Y' ?

INPUT
Value1

STOP

INPUT
Operator

Yes
OUTPUT
Value1 +
Value2

OUTPUT
Value1 –
Value2

IS Operator =
'S' ?
No

Yes

IS Operator =
'M' ?

OUTPUT
Value1 *
Value2

ĬÑĊ®Ġ´íÈõÏĪÅĊàùµþ×
ĬàĒóÐĝûòêþāçÖĊûĊùĂ
ĥÕĕĕµµąÕåÅåąąÕĥÕµÕ

DO NOT WRITE IN THIS MARGIN

No
Yes

© UCLES 2025

INPUT
Value2

IS Operator =
'A' ?

DO NOT WRITE IN THIS MARGIN

7

,

No
OUTPUT
Value1 /
Value2

0478/22/F/M/25

DO NOT WRITE IN THIS MARGIN

,

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

* 0000800000006 *

7
,

,

(a) Complete the trace table for the input data:
Y, 7, S, 9, Y, 5, M, 12, Y, 25, D, 5, N, 10, A, 6
Answer

Value1

Operator

Value2

OUTPUT

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

* 0000800000007 *

[5]
(b) State the purpose of the algorithm on page 6.
[1]
(c) There are problems with the given algorithm. If the lower-case letter ‘y’ is entered for Answer,
the algorithm stops and if a lower-case letter is entered for Operator, the algorithm gives an
incorrect output.
(i)

Explain how you would change the algorithm to prevent the problems described.

DO NOT WRITE IN THIS MARGIN

[3]
(ii)

Identify one more error related to inputs when the algorithm is run.

[1]

© UCLES 2025

ĬÓĊ®Ġ´íÈõÏĪÅĊàûµþ×
ĬàđôØī÷ĂÏüðĢĂòßĊĉĂ
ĥÕĥÕõÕĥµµµõąąµąĕåÕ

0478/22/F/M/25

[Turn over

Code

City

Capital

Country

Continent

Population

ASY6

Abu Dhabi

TRUE

United Arab Emirates

Asia

1,566,999

EUY3

Amsterdam

TRUE

Netherlands

Europe

1,174,025

ASY1

Beijing

TRUE

China

Asia

21,766,214

SAY1

Buenos Aires

TRUE

Argentina

South America

15,490,415

AFY1

Cairo

TRUE

Egypt

Africa

22,183,200

EUN1

Frankfurt

FALSE

Germany

Europe

796,437

ASY3

Jakarta

TRUE

Indonesia

Asia

11,248,839

ASN3

Karachi

FALSE

Pakistan

Asia

17,236,230

ASY4

Kuala Lumpur

TRUE

Malaysia

Asia

8,621,724

AFN2

Lagos

FALSE

Nigeria

Africa

15,945,912

SAY2

Lima

TRUE

Peru

South America

11,206,000

EUY1

London

TRUE

UK

Europe

9,648,110

EUY4

Madrid

TRUE

Spain

Europe

6,751,374

ASN2

Mumbai

FALSE

India

Asia

21,296,516

NAN1

New York City

FALSE

USA

North America

7,888,121

EUY2

Paris

TRUE

France

Europe

11,206,000

ASN1

Shanghai

FALSE

China

Asia

29,210,808

ASY5

Singapore

TRUE

Singapore

Asia

6,080,859

AUN1

Sydney

FALSE

Australia

Australia

5,120,894

ASY2

Tokyo

TRUE

Japan

Asia

37,194,104

NAN2

Toronto

FALSE

Canada

North America

6,371,958

EUN2

Valencia

FALSE

Spain

Europe

838,301

SAN1

Valencia

FALSE

Venezuela

South America

1,983,445

(a) State the number of fields and records in this database table.
Fields
Records
[2]

© UCLES 2025

ĬÑĊ®Ġ´íÈõÏĪÅĊÞùµĀ×
ĬàđñØġąćìö÷ĩäÎýĚñĂ
ĥĥµÕµÕĥĕÕĕąąÅµåĕµÕ

0478/22/F/M/25

DO NOT WRITE IN THIS MARGIN

A database table, MajorCity, stores some details about a number of cities from around the
world.

DO NOT WRITE IN THIS MARGIN

,

DO NOT WRITE IN THIS MARGIN

8



DO NOT WRITE IN THIS MARGIN

8
,

DO NOT WRITE IN THIS MARGIN

* 0000800000008 *

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

* 0000800000009 *

9
,



,

(b) Identify the field in the database table that is most suitable to be the primary key and give
one reason for your choice.
Primary key field
Reason

[2]
(c) Give the output from the structured query language (SQL) statement:
SELECT City, Country, Population
FROM MajorCity
WHERE Continent = "South America"
ORDER BY Population;

DO NOT WRITE IN THIS MARGIN

[3]
(d) Complete the SQL statement to list only the code, city, country and continent of all the cities
in the database table that are capital cities.
SELECT

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

[4]

© UCLES 2025

ĬÓĊ®Ġ´íÈõÏĪÅĊÞûµĀ×
ĬàĒòÐħĉ÷ÍĄĊàøæÙĚāĂ
ĥĥÅĕõµąõÅĥÕąÅÕÅÕåÕ

0478/22/F/M/25

[Turn over

DO NOT WRITE IN THIS MARGIN

* 0000800000010 *

10
,

9

,

Consider this logic expression:
Z = (A NAND B) XOR (NOT (NOT B NAND C))
(a) Draw a logic circuit for this logic expression.
Each logic gate must have a maximum of two inputs.

A

B

Z

C

[5]
(b) Complete the truth table from the given logic expression.
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

Z

DO NOT WRITE IN THIS MARGIN

B

[4]

© UCLES 2025

ĬÑĊ®Ġ´íÈõÏĪÅĊßù·þ×
ĬàĔñÍģýđæíðÃÀÐĩâĉĂ
ĥµÕĕµÕÅĕõåąÅÅĕåĕąÕ

0478/22/F/M/25

DO NOT WRITE IN THIS MARGIN

A

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

Do not simplify the logic expression.

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

* 0000800000011 *

,

© UCLES 2025
,

11

BLANK PAGE

ĬÓĊ®Ġ´íÈõÏĪÅĊßû·þ×
ĬàēòÕĥāġÓċāĆĜè­âùĂ
ĥµåÕõµåõĥÕÕÅÅõÅÕĕÕ

0478/22/F/M/25

[Turn over

12
,

,

10 A sports club uses a six-character alphanumeric membership code to identify each member of the
club.
The one-dimensional (1D) array MemberID[] is used to store the unique membership codes for
club members.
The two-dimensional (2D) array Name[] is used to store the names of the club members. The first
and last name of each member will be stored in separate array elements.

DO NOT WRITE IN THIS MARGIN

* 0000800000012 *

Write a program that meets the following requirements:

•
•
•

•
•

Provide a menu that offers the choices: inputting a new member, outputting a list of
membership codes and first and last names, or stopping.
Input and validate a response to the menu.
When inputting a new member, input a new membership code and check that it contains six
characters:
○ If the new code is six characters, check it against all the previously stored membership
codes to make sure it is unique.
○ If the code is not unique, a new code must be entered and checked.
○ If the code is unique, it is stored in the first available space in the appropriate array
and the new member is required to enter their first name and last name, which are also
stored in the corresponding location of the appropriate array.
When outputting a list of membership codes and names, output for each member: their
membership code, first name and last name.
The program will continue until the stop option on the menu is selected.

You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays, variables or constants; assume this has already been
done.
You do not need to initialise the data in the arrays.
You do need to initialise any variables or constants used if appropriate.
All inputs and outputs must contain suitable messages.

DO NOT WRITE IN THIS MARGIN

The variable NewID is used to input a new membership code.

DO NOT WRITE IN THIS MARGIN

The position of any member’s data is the same in both arrays. For example, the data in index 2 of
MemberID[] belongs to the member in index 2 of Name[]

DO NOT WRITE IN THIS MARGIN

The system can store details for a maximum of 1000 members.

© UCLES 2025

ĬÑĊ®Ġ´íÈõÏĪÅĊÝù·Ā×
ĬàēóÕğóĨèąĊýºČď²āĂ
ĥąõÕµµåÕąõåÅąõĥÕąÕ

0478/22/F/M/25

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

* 0000800000013 *

13
,

,

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/F/M/25

[Turn over

14
,

,

DO NOT WRITE IN THIS MARGIN

* 0000800000014 *

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

[15]
© UCLES 2025

ĬÍĊ®Ġ´íÈõÏĪÅĊÞü¶Ă×
ĬàēòÐħĄĠãõôħÂé¿ĂùĂ
ĥåąÕµµąĕõĕõąÅÕåÕÅÕ

0478/22/F/M/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

DO NOT WRITE IN THIS MARGIN

DO NOT WRITE IN THIS MARGIN

* 0000800000015 *

,

© UCLES 2025
,

15

BLANK PAGE

ĬÏĊ®Ġ´íÈõÏĪÅĊÞú¶Ă×
ĬàĔñØġĀĐÖăýâĖÑěĂĉĂ
ĥåõĕõÕĥõĥĥåąÅµÅĕÕÕ

0478/22/F/M/25

16
,

,

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/F/M/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

* 0000800000016 *

Advertisement