Computer Science (0478) · May/June 2024 · Question paper 23
Cambridge Computer Science (0478) question paper for paper 23, May/June 2024 — 0478/23/M/J/24, file 0478_s24_qp_23.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge IGCSE™
* 5 2 9 6 2 2 3 7 5 6 *
COMPUTER SCIENCE
Paper 2 Algorithms, Programming and Logic
0478/23
May/June 2024
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 (CE/CB) 329120/3
© UCLES 2024
[Turn over
2
1
www.dynamicpapers.com
Tick (3) one box to complete this sentence.
This flowchart symbol
A
represents a subroutine.
B
represents a decision.
C
represents an input/output.
D
represents a terminator.
[1]
2
(a) Four logic gate symbols and five logic functions are shown.
Draw one line to link each logic gate symbol to the appropriate logic function.
Not all logic functions will be used.
Logic gate symbol
Logic function
AND
XOR
NOT
NAND
OR
[4]
© UCLES 2024
0478/23/M/J/24
3
www.dynamicpapers.com
(b) Complete the truth table for this logic circuit.
A
B
Z
C
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
Z
[4]
3
Describe the characteristics of the string and char data types and give an example of each.
String
Example
Char
Example
[4]
© UCLES 2024
0478/23/M/J/24
[Turn over
4
4
www.dynamicpapers.com
This pseudocode algorithm is intended to allow data for up to 50 people to be entered and stored
in a two-dimensional (2D) array. The data is their last name, first name and the city in which they
live.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
DECLARE
DECLARE
DECLARE
DECLARE
FOR I
FOR
People : ARRAY[1:50, 1:3] OF REAL
Count : INTEGER
Response : CHAR
Continue : BOOLEAN
1 TO 50
J
1 TO 3
People[I, J]
""
NEXT J
NEXT I
Count
100
Continue
TRUE
CASE OF
OUTPUT "Enter the last name"
INPUT People[Count, 1]
OUTPUT "Enter the first name"
INPUT People[Count, 2]
OUTPUT "Enter the city"
INPUT People[Count, 3]
OUTPUT "Do you want to enter another name (Y or N)?"
INPUT Response
IF Response = 'N'
THEN
Continue
FALSE
ELSE
Count
Count + 1
ENDIF
UNTIL NOT Count
(a) Identify the line numbers of the four errors in the pseudocode and suggest corrections.
Error 1 line number
Correction
Error 2 line number
Correction
Error 3 line number
Correction
Error 4 line number
Correction
[4]
© UCLES 2024
0478/23/M/J/24
5
www.dynamicpapers.com
(b) Write the pseudocode that you could add to the end of this algorithm to output the contents of
the array. Make sure that the output ends when the data in the array ends.
[4]
(c) Explain how you could alter the original corrected algorithm to make sure that the
number of elements being added to the array does not exceed the maximum size of the
array (50 elements).
[4]
© UCLES 2024
0478/23/M/J/24
[Turn over
6
5
www.dynamicpapers.com
The flowchart represents an algorithm.
START
L
0
S
10000
T
0
A
0
INPUT
Limit
Count
1
INPUT
Value
IS
Value < S
?
No
IS
Value > L
?
No
Yes
Yes
S
L
Value
T
IS
Count >
Limit ?
No
Count
Yes
A
T / Limit
OUTPUT "L = ", L, " S = ",
S, " T = ", T, " A = ", A
STOP
© UCLES 2024
0478/23/M/J/24
Value
T + Value
Count + 1
www.dynamicpapers.com
7
(a) Complete the trace table for the input data:
10, 30, 18, 8, 25, 12, 17, 2, 50, 15, 5
L
S
T
A
Limit
Count
Value
OUTPUT
[6]
(b) Outline the purpose of the algorithm.
[2]
© UCLES 2024
0478/23/M/J/24
[Turn over
www.dynamicpapers.com
8
(c) Explain why the identifiers L, S, T and A may not be appropriate to use as identifiers and how
they could be improved.
[3]
(d) State a more appropriate identifier for each of the variables L, S, T and A
Original identifier
Improved identifier
L
S
T
A
[2]
6
A program is to be written that will accept integers that are between the values of 1 and 80
inclusive.
(a) Give examples of normal, abnormal and extreme test data that could be used to make sure
the program only accepts valid data.
Normal test data
Abnormal test data
Extreme test data
[3]
(b) Describe what is meant by extreme test data.
[2]
© UCLES 2024
0478/23/M/J/24
9
7
www.dynamicpapers.com
(a) The string operation SUBSTRING(FullText, X, Y) returns a string from FullText
beginning at position X that is Y characters long. The first character in FullText is in
position 1.
Write the pseudocode statements to:
•
•
•
store the string “IGCSE Computer Science at Cambridge” in FullText
extract and display the words “Computer Science” from the string and store it in a suitable
variable
output the original string in upper case.
[4]
(b) Write the pseudocode statements to:
•
•
store the content of the variable you created in part (a) to a text file named
"Subjects.txt"
close the text file at the end of the algorithm.
[3]
© UCLES 2024
0478/23/M/J/24
[Turn over
www.dynamicpapers.com
10
8
A database table called Hangar1 stores details of a collection of historic aircraft at a museum.
ID
Make
Model
Year
Engines
Airworthy
JM1
Hawker Siddeley
Nimrod
1966
4
Y
JM2
Douglas
DC-10
1970
3
Y
JM3
Aérospatiale-BAC
Concorde
1973
4
N
PB1
De Havilland
DH-9
1918
1
Y
PB2
Hawker
Fury
1935
1
Y
PB3
Hawker
Nimrod
1934
1
Y
PM1
Fieseler
Storch
1942
1
N
PM2
Hawker
Hurricane
1942
1
Y
PM3
Supermarine
Spitfire
1942
1
N
PM4
Douglas
C-47 Dakota
1942
2
N
PS1
Boeing
314 Clipper
1936
4
N
(a) State the number of fields and records in the database table.
Fields
Records
[2]
(b) Give the output that would be produced by the structured query language (SQL) statement:
SELECT Model, Year, Engines
FROM Hangar1
WHERE Engines > 1
ORDER BY Year;
[4]
© UCLES 2024
0478/23/M/J/24
11
www.dynamicpapers.com
(c) Complete the SQL statement to display only the ID and model of all the aircraft that are
airworthy.
SELECT ID,
;
[4]
© UCLES 2024
0478/23/M/J/24
[Turn over
12
9
www.dynamicpapers.com
A one-dimensional (1D) array Teams[] contains the names of 10 football teams in a local league.
A two-dimensional (2D) array Results[] stores, for each team, the total number of:
•
•
•
•
games won
games drawn
games lost
points.
The position of any team’s data is the same in both arrays. For example the data in index 3 of
Results[] belongs to the team in index 3 of Teams[]
The array data will be used to find the current leader of the league.
The variable Played stores the number of games played by each team. Each team plays the
same number of games.
Write a program that meets the following requirements:
•
•
•
•
•
•
•
•
allows the number of games played to be input and stored, with a maximum of 18 games
allows the names of the teams to be input and stored
allows the number of games won, drawn and lost to be input and stored for each team
validates the number of games played and the number of games won, drawn or lost against
the number of games played
calculates and stores the number of points for each team using three points for a win and one
point for a draw; there are no points for a loss
sorts the array Results[] into descending order of number of points, ensuring the
corresponding parallel array Teams[] is kept in the same order
determines how many teams have the highest number of points
outputs the name(s) of the winning team(s) along with the number of points achieved.
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; you may assume that this has
already been done.
All inputs and outputs must contain suitable messages.
© UCLES 2024
0478/23/M/J/24
13
www.dynamicpapers.com
© UCLES 2024
0478/23/M/J/24
[Turn over
14
www.dynamicpapers.com
[15]
© UCLES 2024
0478/23/M/J/24
15
BLANK PAGE
© UCLES 2024
0478/23/M/J/24
www.dynamicpapers.com
16
www.dynamicpapers.com
BLANK PAGE
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 2024
0478/23/M/J/24