Computer Science (0478) · May/June 2023 · Question paper 23
Cambridge Computer Science (0478) question paper for paper 23, May/June 2023 — 0478/23/M/J/23, file 0478_s23_qp_23.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge IGCSE™
* 5 0 9 3 7 8 1 8 6 5 *
COMPUTER SCIENCE
Paper 2 Algorithms, Programming and Logic
0478/23
May/June 2023
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 (CJ/CGW) 313989/4
© UCLES 2023
[Turn over
2
1
www.dynamicpapers.com
Tick (3) one box to complete the sentence.
A constant
A
stores a value that can change at any time during the execution of a program.
B
stores a value that cannot change during the execution of a program.
C
stores values of multiple data types.
D
stores values that must be of the same data type.
[1]
2
Explain the purpose of the library routines MOD and RANDOM
MOD
RANDOM
[4]
3
Describe what happens when a function is called during the execution of a program.
[3]
© UCLES 2023
0478/23/M/J/23
3
4
www.dynamicpapers.com
(a) Explain why verification checks are used when data is input.
[2]
(b) Give two types of verification check and state how each one can be used.
Verification check 1
Use
Verification check 2
Use
[4]
© UCLES 2023
0478/23/M/J/23
[Turn over
4
5
www.dynamicpapers.com
(a) Four descriptions of validation checks are shown.
Draw one line to link each description to the most appropriate check.
Not all checks will be used.
Description
Check
to check that the data entered is an integer
check digit
to check that some data has been entered
format check
length check
to check that the data entered has an appropriate
number of characters
to check that an identification number contains
no errors
presence check
type check
[4]
(b) Write an algorithm in pseudocode to make sure that an input for the variable Length is
between 15 and 35 inclusive. The code must iterate until a valid input has been made and the
code must include appropriate messages.
[3]
6
An algorithm has been written in pseudocode to allow 100 positive numbers to be input. The total
and the average of the numbers are output.
01
02
03
04
05
06
07
08
09
10
11
12
100
Counter
0
Total
WHILE Counter > 100 DO
INPUT Number
IF Number > 0
THEN
Total + Counter
Total
Counter + 1
Counter
ENDCASE
ENDWHILE
OUTPUT "The total value of your numbers is ", Total
OUTPUT "The average value of your numbers is ", Total / 100
© UCLES 2023
0478/23/M/J/23
5
www.dynamicpapers.com
(a) Identify the four errors in the pseudocode and suggest corrections.
Error 1
Correction
Error 2
Correction
Error 3
Correction
Error 4
Correction
[4]
(b) Describe the changes you should make to the corrected algorithm so that a count-controlled
loop is used to allow 100 positive numbers to be input.
You do not need to rewrite the algorithm.
[5]
© UCLES 2023
0478/23/M/J/23
[Turn over
www.dynamicpapers.com
6
7
The flowchart represents an algorithm.
An input of –1 will terminate the algorithm.
START
Total
0
INPUT
Value
IS
Value =
–1 ?
No
OUTPUT
"Rejected"
Five1
OUTPUT
Total
Value DIV 5
Value / 5
Five2
IS
Five1 =
Five2 ?
No
Yes
Value DIV 10
Ten1
Value / 10
Ten2
No
Total
© UCLES 2023
Total + Value
Yes
IS
Ten1 =
Ten2 ?
Yes
0478/23/M/J/23
STOP
7
www.dynamicpapers.com
(a) Complete the trace table for the input data:
5, 50, 52, 555, 57, 500, –1, 5500, 55
Total
Value
Five1
Five2
Ten1
Ten2
OUTPUT
[6]
(b) Describe the purpose of the algorithm.
[2]
© UCLES 2023
0478/23/M/J/23
[Turn over
8
8
www.dynamicpapers.com
Consider the logic expression:
Z is 1 if (A = 1 AND C = NOT 1) AND (B = 1 NOR C = 1)
(a) Draw a logic circuit for this logic expression.
Each logic gate must have a maximum of two inputs.
Do not simplify this logic expression.
A
B
Z
C
[4]
(b) Complete the truth table from the given logic expression.
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]
© UCLES 2023
0478/23/M/J/23
9
9
www.dynamicpapers.com
The variable Saying is used to store string data in a program.
(a) Write the pseudocode statement to declare the variable Saying
[1]
(b) Write the pseudocode statements to:
•
allow a string to be input to the variable Saying
•
store the content of the variable Saying in a text file named "Quotations.txt"
•
make sure the text file is closed at the end of the algorithm.
[5]
© UCLES 2023
0478/23/M/J/23
[Turn over
10
www.dynamicpapers.com
10 A database table called Site1 stores details of some holiday homes at a holiday park. The
database shows the type of home, number of guests, whether it is privately owned and the weekly
rate to hire it.
Name
Type
Private
Rate$
NumberGuest
Bay Lodge
Lodge
NO
1000
10
Bay View
Cabin
NO
400
4
Blue Skies
Cabin
NO
350
4
Cliff View
Cabin
NO
650
6
Coppice Lodge
Lodge
NO
1200
12
Green Lodge
Lodge
NO
1000
8
Henry
Cabin
YES
300
2
Hikers’ Rest
Retreat
NO
750
6
Poppy
Cabin
NO
300
2
Summer Joy
Retreat
YES
750
6
Valley View
Cabin
NO
600
6
West Lodge
Lodge
YES
1200
12
(a) State the number of fields and the number of records in this database table.
Fields
Records
[2]
(b) Describe the purpose of a primary key.
[1]
© UCLES 2023
0478/23/M/J/23
11
www.dynamicpapers.com
(c) The database uses the data types:
•
alphanumeric
•
character
•
Boolean
•
integer
•
real
•
date/time.
Complete the table to show the most appropriate data type for each field.
Field
Data type
Type
Private
Rate$
NumberGuest
[2]
(d) Give the output that would be produced by the structured query language (SQL) statement:
SELECT Name, NumberGuest, Rate$
FROM Site1
WHERE NumberGuest >= 10;
[3]
© UCLES 2023
0478/23/M/J/23
[Turn over
12
11
www.dynamicpapers.com
A two-dimensional (2D) array Contacts[] is used to store names and telephone numbers. All
the data is stored as strings. The array must have the capacity to store 100 contacts in the form of:
•
column 1 – contact names as: last name, first name
for example: Smith, John
•
column 2 – telephone numbers.
The variable CurrentSize shows how many contacts are in the array.
Write a program that meets the following requirements:
display a menu of choices:
○ enter new contact details
○ display all the contact details
○ delete all the contact details
•
validate the menu input
•
allow up to a maximum of five new contacts to be added to the array at any one time
•
do not allow more than 100 contacts in total
•
after new contacts have been added, sort the array by contact name, as long as there are at
least two contacts in the array
•
output the whole of the array
•
delete the contents of the array.
•
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.
You do not need to initialise the data in the array Contacts[] and the variable CurrentSize
© UCLES 2023
0478/23/M/J/23
13
www.dynamicpapers.com
© UCLES 2023
0478/23/M/J/23
[Turn over
14
www.dynamicpapers.com
[15]
© UCLES 2023
0478/23/M/J/23
15
BLANK PAGE
© UCLES 2023
0478/23/M/J/23
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 2023
0478/23/M/J/23