0478_s24_qp_21
0478_s24_qp_21
* 6 3 7 7 6 2 5 9 4 8 *
1 hour 45 minutes
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.
DC (PQ/CT) 329143/3
© UCLES 2024 [Turn over
2
A validation check to make sure that an email address contains an ‘@’ sign is a
A range check.
B visual check.
C presence check.
D format check.
[1]
2 Four descriptions of programming concepts and five programming concepts are shown.
(a) Draw one line to link each description to the most appropriate programming concept.
function
a subroutine that may not return a value
procedure
a value that is declared and used within a
specific procedure
parameter
a value that a procedure expects you to
supply when it is called
global variable
[4]
(b) Write the pseudocode to use a procedure named Average that passes the values 25 and 50
to the procedure.
CALL Average(25,50)
...................................................................................................................................................
............................................................................................................................................. [2]
(c) Outline the role of procedures and functions in creating a program that is easier to maintain.
- make the program easier to debug
...................................................................................................................................................
- they can eliminate redundant or repeated code
...................................................................................................................................................
- divide the program into smaller or manageable sections
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
..........................................................................................................................................................
Example ...........................................................................................................................................
3
..........................................................................................................................................................
3.1
Example ...........................................................................................................................................
[4]
4 This pseudocode algorithm is intended to allow, at random, between 1 and 20 values to be entered
and totalled. The total and average of the entered values are output at the end of the algorithm.
(a) Identify the line numbers of four errors in the pseudocode and suggest corrections.
1
Error 1 line number ...................................................................................................................
Correction .................................................................................................................................
DECLARE Loop : INTEGER
...................................................................................................................................................
7
Error 2 line number ...................................................................................................................
FOR Loop <-- 1 TO Limit
Correction .................................................................................................................................
...................................................................................................................................................
9
Error 3 line number ...................................................................................................................
INPUT Value
Correction .................................................................................................................................
...................................................................................................................................................
10
Error 4 line number ...................................................................................................................
Correction .................................................................................................................................
Total <-- Total + Value
...................................................................................................................................................
[4]
(b) Write the pseudocode statement that would output the average calculated in line 13 of the
algorithm rounded to one decimal place.
ROUND(Total / Limit,1)
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
(c) Explain how you should alter the original corrected algorithm to make sure that all the
numbers entered are between 1 and 500 inclusive. If any numbers fall outside these limits, a
replacement value is requested and entered.
...................................................................................................................................................
After line 09, insert a WHILE loop to check if entered value is between 1 and
...................................................................................................................................................
500. If the value is not in range, output an error message and use input
...................................................................................................................................................
statement to ask for a new input.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
..........................................................................................................................................................
4 : OUTPUT 4
..........................................................................................................................................................
OTHERWISE OUTPUT "ERROR"
..........................................................................................................................................................
ENDCASE
..........................................................................................................................................................
.................................................................................................................................................... [5]
START
INPUT
Numbers[Count]
STOP
Count Count + 1
No IS Count >
Limit?
IS Numbers[Count] > No
Yes
Numbers[Count + 1]?
Flag TRUE
Yes
Swap Numbers[Count]
IS Flag = No
TRUE?
Numbers[Count] Numbers[Count + 1]
Yes
Flag True
Count Count + 1
Numbers
Limit Count [1] [2] [3] [4] [5] [6] [7] Flag Swap Result OUTPUT
7 1 47
2 50
3 52
4 60
5 80
6 63
7 70
8 TRUE
1 FALSE
2
3
4
5 80
63 80 TRUE
6 80
70 80 TRUE
7
1 FALSE
2
3
4
5
6
7
4 60
[7]
© UCLES 2024 0478/21/M/J/24 [Turn over
8
(b) Outline the processes involved in the algorithm shown in the flowchart on page 6.
- set of numbers inputted
...................................................................................................................................................
...................................................................................................................................................
- median value is found
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
............................................................................................................................................. [2]
...................................................................................................................................................
DECLARE info : STRING
...................................................................................................................................................
OPENFILE Quotation.txt FOR READ
...................................................................................................................................................
READFILE Quotation.txt, info
...................................................................................................................................................
OUTPUT UCASE(info), LENGTH(info)
...................................................................................................................................................
CLOSEFILE Quotation.txt
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
S Z
[5]
(b) Complete the truth table from the given logic expression.
Working space
R S T Z
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
[4]
9 A database table called SoftDrinks stores details of the soft drinks sold by a small shop.
Name Cola
Container Can
SizeCl 330
NumberInStock 30
ReorderLevel 15
Reordered Yes
(a) State whether any of the given fields would be suitable as a primary key and give a reason for
your answer.
none since none are unique
...................................................................................................................................................
............................................................................................................................................. [1]
(b) Complete the structured query language (SQL) statement to return the number of cans the
shop has in stock.
SUM
SELECT ....................................................... NumberInStock
(.......................................................)
FROM .......................................................
SoftDrinks
WHERE .......................................................
Container = .......................................................
'Can' ;
[5]
BLANK PAGE
10 The one-dimensional (1D) array Clubs[] is used to store the names of 12 cricket clubs in a local
sports league.
The two-dimensional (2D) array Statistics[] is used to store, for each cricket club, the number
of:
• matches won
• matches drawn
• matches lost.
The 1D array Points[] is used to store the total number of points each cricket club has been
awarded.
The position of any cricket club’s data is the same in all three arrays. For example, the data in
index 2 of Statistics[] and index 2 of Points[] belongs to the cricket club in index 2 of
Clubs[]
The variable Matches stores the number of matches played by each team. Each team plays the
same number of matches.
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; you may assume that this has already been
done.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
© UCLES 2024 0478/21/M/J/24 [Turn over
14
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................. [15]
© UCLES 2024 0478/21/M/J/24
15
BLANK PAGE
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.