Cspaper 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 164

Cambridge IGCSE™

* 3 0 6 2 8 7 9 6 9 6 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming May/June 2022

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● Do not attempt Tasks 1, 2 and 3 in the copy of the pre-release material on page 2; these are for
information only.
● 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 50.
● 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 12 pages.

DC (KN) 303743/3
© UCLES 2022 [Turn over
2

Section A

You are advised to spend no longer than 40 minutes answering this section.

Here is a copy of the pre-release material.

DO NOT attempt Tasks 1, 2 and 3 now.

Use the pre-release material and your experience from attempting the following tasks before the
examination to answer Question 1.

Pre-release material

Friends of Seaview Pier is an organisation devoted to the restoration and upkeep of a pier in the
town. A pier is a wooden structure that provides a walkway over the sea. The pier requires regular
maintenance and the friends of the pier need to raise money for this purpose.
Members of Friends of Seaview Pier each pay $75 per year, as a contribution to the pier’s running costs.
This entitles them to free admission to the pier throughout the year. They can also volunteer to help run
the pier, by working at the pier entrance gate, working in the gift shop, or painting and decorating.
To provide additional income, the pier’s wooden planks can be sponsored. A brass plaque, which
contains a short message of the sponsor’s choice, is fitted to a plank on the pier, for a donation of
$200.
Write and test a program or programs for the Friends of Seaview Pier:
• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All variables, constants and other identifiers must have meaningful names.
You will need to complete these three tasks. Each task must be fully tested.
Task 1 – becoming a member of Friends of Seaview Pier
Set up a system to enable people to become members of Friends of Seaview Pier and for each new
member enter:
• their first name and last name
• whether or not they wish to work as a volunteer
○ if they choose to volunteer, identify the area from:
– the pier entrance gate
– the gift shop
– painting and decorating
• the date of joining
• whether or not they have paid the $75 fee.
All of this information needs to be stored using suitable data structures.
Task 2 – using the membership data
Extend the program in Task 1 so that a list of the first and last names of members can be output in
any of the following categories:
• Members who have chosen to work as volunteers.
• Volunteers who would like to work at the pier entrance gate.
• Volunteers who would like to work in the gift shop.
• Volunteers who would like to help with painting and decorating tasks.
• Members whose membership has expired (they have not re-joined this year).
• Members who have not yet paid their $75 fee.
Task 3 – sponsoring a wooden plank
Add an additional option to the program in Task 1 to enable the pier’s wooden planks to be
sponsored. Separate data structures should be used to store the names of the individuals and
the short messages they would like to have written on their brass plaque. An output would display
everything that was input for the sponsor to confirm. If errors are found, the program should allow
data to be re-entered. Once complete, the data is stored and the sponsor is charged $200.

© UCLES 2022 0478/21/M/J/22


3

1 (a) Describe the data structures you could have used in Task 1. Your description should include
types of data structure, names used for data structures, their uses and examples of sample
data.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

(b) Explain how you could change your program in Task 1 to total all the money collected from
new members who have paid.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Describe how data input in Task 1 could be validated to find out if a new member wants to
work as a volunteer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/M/J/22 [Turn over


4

(d) Write an algorithm to show how your program completes Task 3 assuming the option to
sponsor a wooden plank has been chosen, using pseudocode, programming statements or a
flowchart. Details completed in Task 1 are not required.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2022 0478/21/M/J/22


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]
© UCLES 2022 0478/21/M/J/22 [Turn over
6

(e) Explain how your program allows any one of the member or volunteer lists to be selected and
displayed (part of Task 2). Any programming statements used in your answer must be fully
explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/21/M/J/22


7

Section B

2 Tick (ü) one box in each row to identify the most appropriate data type for each description. Only
one tick (ü) per column.

Data type
Description
Boolean Char Integer Real String
a single character from the keyboard

multiple characters from the keyboard

only one of two possible values

only whole numbers

any number
[4]

3 Give one piece of normal test data and one piece of erroneous test data that could be used to
validate the input of an email address.

State the reason for your choice in each case.

Normal test data ...............................................................................................................................

..........................................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Erroneous test data ..........................................................................................................................

..........................................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2022 0478/21/M/J/22 [Turn over


8

4 The flowchart shows an algorithm that should allow 60 test results to be entered into the variable
Score. Each test result is checked to see if it is 50 or more. If it is, the test result is assigned to the
Pass array. Otherwise, it is assigned to the Fail array.

(a) Complete this flowchart:

START

PassCount 0

FailCount 0

Count 0

Yes No

Count Count + 1

No

Yes

END

[6]
© UCLES 2022 0478/21/M/J/22
9

(b) Write a pseudocode routine that will check that each test result entered into the algorithm is
between 0 and 100 inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/21/M/J/22 [Turn over


10

5 The pseudocode represents an algorithm.

The pre-defined function DIV gives the value of the result of integer division.
For example, Y = 9 DIV 4 gives the value Y = 2

The pre-defined function MOD gives the value of the remainder of integer division.
For example, R = 9 MOD 4 gives the value R = 1

First ← 0
Last ←
0
INPUT Limit
FOR Counter ← 1 TO Limit
INPUT Value
IF Value >= 100
THEN
IF Value < 1000
THEN
First ← Value DIV 100
Last ←Value MOD 10
IF First = Last
THEN
OUTPUT Value
ENDIF
ENDIF
ENDIF
NEXT Counter

(a) Complete the trace table for the algorithm using this input data:

8, 66, 606, 6226, 8448, 642, 747, 77, 121

Counter Value First Last Limit OUTPUT

[5]

© UCLES 2022 0478/21/M/J/22


11

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 0478/21/M/J/22 [Turn over


12

6 A computer game shop records its stock levels in a database table called GAMES. The fields used
in the stock table are shown.

Name Description
GameID primary key
GameName the name of each game
AgeRestriction the minimum age at which a person is allowed to play each game
GamePrice the selling price for each game
NumberStock the quantity of each game currently in stock
OnOrder whether or not each game is on order from the suppliers
DateLastOrdered the date the most recent order for each game was placed
GameDescription a summary of the contents and purpose of each game

(a) State the number of fields that are in the table GAMES.

............................................................................................................................................. [1]

(b) State one important fact that must be true for a field to be a primary key.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Complete the query-by-example grid to output all the games that have no stock and that are
on order with the supplier. Display only the GameID, GameName and GamePrice fields in
alphabetical order of the name of the game.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

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 2022 0478/21/M/J/22


Cambridge IGCSE™
* 6 5 6 8 1 1 8 8 5 0 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming May/June 2022

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● Do not attempt Tasks 1, 2 and 3 in the copy of the pre-release material on page 2; these are for
information only.
● 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 50.
● 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 12 pages.

DC (PQ) 303914/4
© UCLES 2022 [Turn over
2

Section A

You are advised to spend no longer than 40 minutes answering this section.

Here is a copy of the pre-release material.

DO NOT attempt Tasks 1, 2 and 3 now.

Use the pre-release material and your experience from attempting the following tasks before the
examination to answer Question 1.

Pre-release material
A program is needed to allow a Wildlife Park to sell tickets. A booking consists of one or more tickets for
the same day(s) and can be made up to a week in advance. A booking can be made for a visit of one day
or two consecutive days. A booking can have extra attractions included. A booking will be valid for the
day(s) chosen only.

Ticket type Cost for one day Cost for two days
one adult $20.00 $30.00
one child (an adult may bring up to two children) $12.00 $18.00
one senior $16.00 $24.00
family ticket (up to two adults or seniors, and three children) $60.00 $90.00
groups of six people or more, price per person $15.00 $22.50

Extra attraction Cost per person


lion feeding $2.50
penguin feeding $2.00
evening barbecue (two-day tickets only) $5.00

Write and test a program or programs for the Wildlife Park:


• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All variables, constants and other identifiers must have meaningful names.

You will need to complete these three tasks. Each task must be fully tested.

Task 1 – displaying the ticket options and the extra attractions available
Set up your program to:
• display the options, attractions and prices for one-day tickets
• display the options, attractions and prices for two-day tickets
• show the days available for booking; assume that there are tickets available for any valid day.

Task 2 – process a booking


Extend your program for Task 1 to:
• input the tickets and extra attractions required, then calculate the total cost of the booking
• allocate a unique booking number
• display the booking details, including the total cost and the unique booking number
• repeat as required.

Task 3 – ensuring each booking is the best value


Check that the total for each booking gives the best value and offer an alternative if this is not the case.
For example, buying two family tickets is better than a group ticket for a group of 10 that includes
four adults and six children.
© UCLES 2022 0478/22/M/J/22
3

1 All variables, constants and other identifiers must have meaningful names.

(a) (i) Identify one constant that you could have used for Task 1.
Give the value and use of the constant.

Constant ............................................................................................................................

Value .................................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[3]

(ii) Identify one variable that you could have used for Task 2.
Give the data type and use of the variable.

Variable .............................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[3]

(b) Explain how your program showed the days available for booking in Task 1.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Explain how your program made sure that each booking number allocated in Task 2 was
unique.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 0478/22/M/J/22 [Turn over


4

(d) Write an algorithm for the part of Task 2 that inputs the tickets and extra attractions required
then calculates the total cost of the booking.

Assume that the booking is for a single day.

Use pseudocode, programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2022 0478/22/M/J/22
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2022 0478/22/M/J/22 [Turn over


6

(e) Explain how your program decides when a family ticket is better value in Task 3.

Any programming statements that you include in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/22/M/J/22


7

Section B starts on page 8

© UCLES 2022 0478/22/M/J/22 [Turn over


8

Section B

2 An algorithm allows a user to input their password and checks that there are at least eight
characters in the password. Then, the user is asked to re-input the password to check that both
inputs are the same. The user is allowed three attempts at inputting a password of the correct
length and a matching pair of passwords. The pre-defined function LEN(X) returns the number of
characters in the string, X

01 Attempt 0 ←
02 REPEAT
03 PassCheck TRUE ←
04 OUTPUT "Please enter your password "
05 INPUT Password
06 IF LEN(Password) < 8
07 THEN
08 PassCheck TRUE ←
09 ELSE
10 OUTPUT "Please re-enter your password "
11 INPUT Password2
12 IF Password <> Password
13 THEN
14 PassCheck FALSE ←
15 ENDIF
16 ENDIF
17 Attempt ←
Attempt + 1
18 UNTIL PassCheck OR Attempt <> 3
19 IF PassCheck
20 THEN
21 OUTPUT "Password success"
22 ELSE
23 OUTPUT "Password fail"
24 ENDIF

(a) Identify the three errors in the pseudocode and suggest a correction to remove each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................
[3]

© UCLES 2022 0478/22/M/J/22


9

(b) The algorithm includes two types of check on the data input.
Identify and describe each type of check.

Type of check 1 ........................................................................................................................

Description ................................................................................................................................

...................................................................................................................................................

Type of check 2 ........................................................................................................................

Description ................................................................................................................................

...................................................................................................................................................
[4]

(c) Give two sets of test data for this algorithm and a reason for choosing each set.

Each set of test data and its reason must be different.

Set 1 .........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Set 2 .........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

3 (a) Describe a one-dimensional array. Include an example of an array declaration.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Explain how indexing could be used to search for a value stored in a one-dimensional array.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 0478/22/M/J/22 [Turn over


10

4 This algorithm checks the temperature of hot food being served to customers.
Error

START

Counter 0
Hot 0
Cold 0
Serve 0

INPUT Temp

Is Temp Yes Error


= –1? ((Hot + Cold) / Counter) * 100

No

Is Temp Yes OUTPUT


Hot Hot + 1
> 86? "Too Hot"

Counter No
Counter + 1 OUTPUT
Error
Is Temp Yes
Cold Cold + 1
< 63?
No
OUTPUT
Serve Serve + 1 "Too Cold"
END

© UCLES 2022 0478/22/M/J/22


11

(a) Complete the trace table for the algorithm using this input data:

75, 78, 84, 87, 91, 80, 75, 70, 65, 62, –1, 20

Counter Hot Cold Serve Temp Error OUTPUT

[7]

(b) State how the final output from the algorithm could be improved.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Identify the process in the algorithm that is not required.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2022 0478/22/M/J/22 [Turn over


12

5 A database table, NURSE, is used to keep a record of disposable items worn by veterinary nurses.

This is part of the table:

ItemNumber Description SingleUse Uses StockLevel ReorderLevel

DIG1 Glove (pair) Y 1 500 800

DIA1 Apron Y 1 700 800

DIM5 Hair net Y 1 650 500

DIA2 Apron N 5 25 100

DIS4 Suit N 3 70 50

DIV9 Shoe cover (pair) Y 1 400 250

(a) Complete this query-by-example grid to display only the item number and the description of
single use items, where the stock level is below the reorder level.

Field:

Table:

Sort:

Show:

Criteria:

or:
[4]

(b) Give a reason why the field SingleUse is not required in the table NURSE.

...................................................................................................................................................

............................................................................................................................................. [1]

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


Cambridge IGCSE™
* 8 1 1 3 9 3 2 4 8 5 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming May/June 2022

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● Do not attempt Tasks 1, 2 and 3 in the copy of the pre-release material on page 2; these are for
information only.
● 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 50.
● 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 12 pages. Any blank pages are indicated.

DC (CJ) 303921/2
© UCLES 2022 [Turn over
2

Section A

You are advised to spend no longer than 40 minutes answering this section.
Here is a copy of the pre-release material.
DO NOT attempt Tasks 1, 2 and 3 now.
Use the pre-release material and your experience from attempting the following tasks before the
examination to answer Question 1.
Pre-release material

Seaview Castle Visitor Centre is open seven days a week. It offers a range of facilities and activities
including meeting rooms, a permanent fossil exhibition, supervised walks along the cliff tops and an
old stone quarry.
There are three meeting rooms, which can each be booked separately. There is one large room
that can be used for a variety of activities such as showing films, holding presentations, displaying
exhibitions or wedding receptions. There are also two smaller meeting rooms. Each room can be
booked by the day according to the following tariff:

Room Cost per day


large $295
small 1 $175
small 2 $150

Write and test a program or programs to arrange meeting room bookings:


• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All variables, constants and other identifiers must have meaningful names.
You will need to complete these three tasks. Each task must be fully tested.
Task 1 – setting up a booking system structure for the meeting rooms
Set up suitable data structures for each of the three meeting rooms to store:
• when it is booked during a fixed eight-week period
• the client’s name (the person making the booking)
• a unique booking code
• the cost of the booking.
Task 2 – booking a meeting room
Extend the program in Task 1 to enable bookings to be made so that the client enters their name,
the meeting room required and the day of the booking. After the data has been entered, the program
should check if the requested day is available for the required meeting room and if not, the client
should be allowed to enter an alternative day or exit the program.
If the requested day is available, the booking details and cost of the booking should be output for
the client to confirm. Once confirmed, a unique booking code should be generated and stored in
both the appropriate meeting room data structure and the unique booking code data structure. The
client’s name and cost of the booking should be stored in the appropriate data structures set up in
Task 1.
Bookings of more than one day must be entered as separate single day bookings.
Task 3 – using the booking data
Extend the program in Task 1 and Task 2 to make use of the data that is available, to:
• select a meeting room and output the days when it is free
• total and output the amount of money currently taken for all three meeting rooms
• check the bookings for a specific client.
© UCLES 2022 0478/23/M/J/22
3

1 All variables, constants and other identifiers must have meaningful names.

(a) Identify one variable and one array you could have used for Task 1 or Task 2.

Give the use for the variable and array.

Variable .....................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................

Array .........................................................................................................................................

Use ...........................................................................................................................................

............................................................................................................................................. [4]

(b) Describe how you could test if the validation of the input to choose a meeting room works
(Task 2).

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Explain how your program in Task 2 could be altered to allow a 30% discount on bookings for
the same meeting room of two to six days, inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/23/M/J/22 [Turn over


4

(d) Write an algorithm to show how your program completes the following parts of Task 2:

• output the booking details and cost of the booking


• take confirmation from the client
• generate a unique booking code
• store the booking details.

Assume that Task 1 and the first part of Task 2 have been completed.

Assume that the booking is for a single day and that the requested booking day is available.

Use pseudocode, programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2022 0478/23/M/J/22
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2022 0478/23/M/J/22 [Turn over
6

(e) Explain how your program selects a meeting room, finds and then outputs the days when it
is available (part of Task 3). Any programming statements used in your answer must be fully
explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/23/M/J/22


7

Section B

2 Tick (3) one or more boxes in each row to match the type(s) of test data to each description.

Types of test data


Description Erroneous /
Boundary Extreme Normal
Abnormal

test data that is always on the limit of


acceptability

test data that is either on the limit of


acceptability or test data that is just
outside the limit of acceptability

test data that will always be rejected

test data that is within the limits of


acceptability

[4]

3 Describe what is meant by the terms variable and constant and give an example of each in your
answer.

Variable ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Constant ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2022 0478/23/M/J/22 [Turn over


8

4 The pseudocode represents an algorithm.

The pre-defined function DIV gives the value of the result of integer division.
For example, Y = 11 DIV 4 gives the value Y = 2

Count ←0
INPUT Limit
FOR In ←

1 TO Limit
Logic

TRUE
Test 2
INPUT Number
REPEAT
IF Number / Test = Number DIV Test


THEN
Logic FALSE
ELSE
Test ←Test + 1
ENDIF
UNTIL NOT Logic OR Test >= Number DIV 2
IF Logic


THEN


Store[Count] Number
Count Count + 1
ENDIF
NEXT In
FOR Out ←
0 TO Count - 1
OUTPUT Store[Out]
NEXT Out

(a) Complete the trace table for the algorithm using this input data:
5, 9, 5, 8, 10, 7

Store
In Logic Test Number Count Limit Out OUTPUT
[Count]

[7]
© UCLES 2022 0478/23/M/J/22
9

(b) State the purpose of this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) This algorithm only works for numbers that are 3 or greater.

Describe how you could change this algorithm to make sure that only numbers that are
3 or greater are entered. Any pseudocode statements used in your answer must be fully
described.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/23/M/J/22 [Turn over


10

5 The flowchart shows an algorithm that should:


• allow 100 numbers to be entered into the variable Number
• total the numbers as they are entered
• output the total and average of the numbers after they have all been entered.

Complete this flowchart:

START

Total 0

Counter 0

No

Yes

END
[6]
© UCLES 2022 0478/23/M/J/22
11

6 Data about planets in the solar system is stored in a database table called PLANETS. The fields
used in the table are shown.

Name of field Contents of field


PlanetName the name of the planet
PlanetMass the planet’s mass in kilograms
Larger whether or not the planet has a greater mass than Earth
MaxDistance the maximum distance the planet is from Earth in kilometres
MinDistance the minimum distance the planet is from Earth in kilometres
YearLength the length of time it takes for the planet to orbit the Sun in Earth days

(a) State the name of the field that could contain Boolean data.

............................................................................................................................................. [1]

(b) Complete the query-by-example grid to output the planets with a longer year length and
greater mass than Earth. Assume Earth’s year length is 365 days.

Display only the name of the planets sorted in alphabetical order.

Field:

Table:

Sort:

Show: o o o o o
Criteria:

or:
[3]

© UCLES 2022 0478/23/M/J/22


12

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 2022 0478/23/M/J/22


Cambridge IGCSE™
* 4 8 1 6 0 2 0 7 0 1 *

COMPUTER SCIENCE 0478/21


Paper 2 Algorithms, Programming and Logic 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/CT) 313987/4
© UCLES 2023 [Turn over
2

1 (a) Four descriptions of stages in the program development life cycle are shown.

Draw one line to link each description to its most appropriate program development life cycle
stage.

Not all program development life cycle stages will be used.

Program development life cycle description Program development life cycle stage

develop an algorithm to solve the problem analysis


by using structure diagrams, flowcharts or
pseudocode

coding

detect and fix the errors in the program


design

identify the problem and its requirements


evaluation

write and implement the instructions to


solve the problem testing
[4]
(b) Identify three of the component parts after a problem has been decomposed.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

3 ................................................................................................................................................

...................................................................................................................................................
[3]

2 Tick (ü) one box to show the name of the data structure used to store a collection of data of the
same data type.

A Array

B Constant

C Function

D Variable
[1]
© UCLES 2023 0478/21/M/J/23
3

3 (a) Describe what is meant by data validation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) A validation check is used to make sure that any value that is input is an integer between 30
and 200 inclusive.

Give one example of each type of test data to check that the validation check is working as
intended. Each example of test data must be different.

Give a reason for each of your choices of test data.

Normal test data .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Abnormal test data ...................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Extreme test data .....................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[6]

4 Explain the purpose of the library routines DIV and ROUND

DIV ...................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

ROUND ..............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]
© UCLES 2023 0478/21/M/J/23 [Turn over
4

5 An algorithm has been written in pseudocode to allow some numbers to be input. All the positive
numbers that are input are totalled and this total is output at the end.
An input of 0 stops the algorithm.

01 Exit 1←
02 WHILE Exit <> 0 DO
03 INPUT Number
04 IF Number < 0
05 THEN
06 Total ←
Total + Number
07 ELSE
08 IF Number = 0
09 THEN
10 Exit 1 ←
11 ENDIF
12 ENDIF
13 ENDIF
14 OUTPUT "The total value of your numbers is ", Number

(a) Identify the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2023 0478/21/M/J/23


5

(b) Describe how you could change the corrected algorithm to record and output how many
positive numbers have been included in the final total.

You do not need to rewrite the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

6 State two features that should be included to create a maintainable program.

Give a reason why each feature should be used.

1 .......................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2023 0478/21/M/J/23 [Turn over


6

7 The flowchart represents an algorithm.

START

Pointer 1

INPUT
Letter

IS No
Word[Pointer, 1] Pointer Pointer + 1
= Letter ?

Yes

OUTPUT "Letter ", Letter,


" is represented by ",
Word[Pointer, 2]

OUTPUT "Another Letter?


(Y or N)"

INPUT Choice

Yes IS No
Choice = STOP
'Y' ?

© UCLES 2023 0478/21/M/J/23


7

The table represents the two-dimensional (2D) array Word[] which stores the first half of the
phonetic alphabet used for radio transmission. For example, Word[10,1] is ‘J’.

Index 1 2
1 A Alpha
2 B Bravo
3 C Charlie
4 D Delta
5 E Echo
6 F Foxtrot
7 G Golf
8 H Hotel
9 I India
10 J Juliet
11 K Kilo
12 L Lima
13 M Mike

(a) Complete the trace table for the algorithm by using the input data: F, Y, D, N

Pointer Letter Choice OUTPUT

[4]

© UCLES 2023 0478/21/M/J/23 [Turn over


8

(b) Identify the type of algorithm used.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Describe one problem that could occur with this algorithm if an invalid character was input.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/21/M/J/23


9

BLANK PAGE

© UCLES 2023 0478/21/M/J/23 [Turn over


10

8 The function LENGTH(Phrase)calculates the length of a string Phrase

(a) Write the pseudocode statements to:


• store the string "The beginning is the most important part" in Phrase
• calculate and output the length of the string
• output the string in upper case.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Write the output your pseudocode should produce.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/21/M/J/23


11

9 Consider this logic expression.

Z = (NOT A OR B) AND (B XOR C)

(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.

B Z

[4]

(b) Complete the truth table from the given logic expression.

Working space
A B C 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]

© UCLES 2023 0478/21/M/J/23 [Turn over


12

10 A database table called TVRange shows the main features and prices of a range of televisions.

TVCode ScreenSize Satellite SmartTV SoundBar Price$


TV90SaSmSd 90 YES YES YES 9750.00
TV75SaSmSd 75 YES YES YES 8500.00
TV75SaSd 75 YES NO YES 8000.00
TV65SaSmSd 65 YES YES YES 6000.00
TV65SmSd 65 NO YES YES 5000.00
TV65SaSd 65 YES NO YES 5000.00
TV55SaSmSd 55 YES YES YES 4000.00
TV55SaSd 55 YES NO YES 3500.00
TV55SmSd 55 NO YES YES 3500.00
TV50SaSmSd 50 YES YES YES 2500.00
TV50Sa 50 YES NO NO 1750.00
TV50Sm 50 NO YES NO 1750.00
TV40Sa 40 YES NO NO 1200.00
TV40 40 NO NO NO 950.00
TV32 32 NO NO NO 650.00

(a) Give the name of the field that is most suitable to be the primary key.

State the reason for this choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2023 0478/21/M/J/23


13

(b) The database uses the data types:


• text
• character
• Boolean
• integer
• real
• date/time.

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

Field Data type


TVCode
ScreenSize
SmartTV
Price$
[2]

(c) Complete the structured query language (SQL) query to return the television (TV) code,
screen size and price of all Smart TVs in the database table.

SELECT TVCode, ......................................................., .......................................................

....................................................... TVRange

WHERE SmartTV = .......................................................;


[4]

© UCLES 2023 0478/21/M/J/23 [Turn over


14

11 A one-dimensional (1D) array Days[] contains the names of the days of the week. A
two-dimensional (2D) array Readings[] is used to store 24 temperature readings, taken once
an hour, for each of the seven days of the week. A 1D array AverageTemp[] is used to store the
average temperature for each day of the week.

The position of any day’s data is the same in all three arrays. For example, if Wednesday is
in index 4 of Days[], Wednesday’s temperature readings are in index 4 of Readings[] and
Wednesday’s average temperature is in index 4 of AverageTemp[]

The temperature readings are in Celsius to one decimal place. Temperatures can only be from
–20.0 °C to +50.0 °C inclusive.

Write a program that meets the following requirements:


• input and validate the hourly temperatures for one week
• calculate and store the average temperature for each day of the week
• calculate the average temperature for the whole week
• convert all the average temperatures from Celsius to Fahrenheit by using the formula
Fahrenheit = Celsius * 9 / 5 + 32
• output the average temperature in Celsius and in Fahrenheit for each day
• output the overall average temperature in Celsius and in Fahrenheit for the whole week.

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.

All data output must be rounded to one decimal place.

You will need to initialise and populate the array Days[] at the start of the program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/21/M/J/23
15

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/21/M/J/23 [Turn over
16

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

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/21/M/J/23


Cambridge IGCSE™
* 5 0 9 3 7 8 1 8 6 5 *

COMPUTER SCIENCE 0478/23


Paper 2 Algorithms, Programming and Logic 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 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 (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 (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

format check
to check that some data has been entered

length check
to check that the data entered has an appropriate
number of characters
presence check

to check that an identification number contains


no errors 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 Counter 100
02 Total 0
03 WHILE Counter > 100 DO
04 INPUT Number
05 IF Number > 0
06 THEN
07 Total Total + Counter
08 Counter Counter + 1
09 ENDCASE
10 ENDWHILE
11 OUTPUT "The total value of your numbers is ", Total
12 OUTPUT "The average value of your numbers is ", Total / 100

© UCLES 2023 0478/23/M/J/23


5

(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


6

7 The flowchart represents an algorithm.


An input of –1 will terminate the algorithm.

START

Total 0

INPUT
Value

IS Yes
Value =
–1 ?

No OUTPUT
OUTPUT Total
"Rejected" Five1 Value DIV 5

STOP
Five2 Value / 5

No IS
Five1 =
Five2 ?

Yes

Ten1 Value DIV 10

Ten2 Value / 10

No IS
Ten1 =
Ten2 ?

Yes
Total Total + Value
© UCLES 2023 0478/23/M/J/23
7

(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 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.

B Z

[4]
(b) Complete the truth table from the given logic expression.

Working space
A B C 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]

© UCLES 2023 0478/23/M/J/23


9

9 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

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

(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 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

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/23/M/J/23 [Turn over
14

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

© UCLES 2023 0478/23/M/J/23


15

BLANK PAGE

© UCLES 2023 0478/23/M/J/23


16

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


Cambridge IGCSE™
* 0 6 7 5 1 6 4 9 9 2 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming October/November 2022

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● Do not attempt Tasks 1, 2 and 3 in the copy of the pre-release material on page 2; these are for
information only.
● 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 50.
● 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 (NF) 303968/3
© UCLES 2022 [Turn over
2

Section A

You are advised to spend no longer than 40 minutes answering this section.

Here is a copy of the pre-release material.

DO NOT attempt Tasks 1, 2 and 3 now.

Use the pre-release material and your experience from attempting the following tasks before the
examination to answer Question 1.

Pre-release Material

A program is needed for a swimming club to manage the annual audit of its membership details.

The data stored about each member includes name, age, gender, type of membership, whether
a team member or not, annual fee and if the fee has been paid. Team members are allowed a
discount of 10% on their annual membership fee.

The types of membership available are:

Membership Age range in years Annual fee


junior >= 2 and < 18 $10.00
adult >= 18 and < 50 $20.00
senior >= 50 and < 80 $15.00
golden 80 and over free

Write and test a program or programs for the swimming club annual audit:

• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All variables, constants and other identifiers must have meaningful names.

You will need to complete these three tasks. Each task must be fully tested.

Task 1 – setting up the system to store the membership details

Set up your program to:


• store the members’ details in arrays
• populate the arrays with at least 20 members’ details
• use the array index as the annual membership number.

Task 2 – providing annual audit statistics

Count the number of current members by membership type. For each type of membership count the
number of members who did not pay the annual fee. Display these counts as a percentage of the
total number of members for each membership type. Calculate and display the total of the annual
fees expected and the annual fees received for this year.

Task 3 – updating the membership details for the next year

Extend your program to:


• check if any members have not paid and output a list of all these members
• remove these members from the system
• update the age of all the members by one year and whether they are in a team
• update the type of membership and the annual fee if required
• set the fee for every member as not yet paid
• display lists of current team members grouped by membership type.

© UCLES 2022 0478/21/O/N/22


3

1 All variables, constants and other identifiers must have meaningful names.

(a) (i) Describe the arrays you have set up in Task 1 to record the members’ details. Include in
your description the name, data type and sample data for each array.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [5]

(ii) Explain how your program for Task 1 populated the arrays with the members’ details.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(b) Explain how your program removed the members that have not paid their fees from the
system in Task 3.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 0478/21/O/N/22 [Turn over


4

(c) Write an algorithm for the part of Task 3 that checks the age of all the members, and whether
they are in a team, then updates the type of membership and the annual fee if required.

Use pseudocode, programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2022 0478/21/O/N/22
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2022 0478/21/O/N/22 [Turn over


6

(d) Explain how your program completes these parts of Task 2:

• Count the number of members of each membership type who did not pay the annual
fee.
• Display these counts as a percentage of the total number of members for each
membership type.

Any programming statements that you include in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2022 0478/21/O/N/22


7

Section B starts on page 8.

© UCLES 2022 0478/21/O/N/22 [Turn over


8

Section B

2 An algorithm has been written to:

• set 100 elements of the array Reading[1:100] to zero


• input integer values between 1 and 100
• end the process with an input of –1
• reject all other values
• count and output the number of times each value is input, starting with the largest value.

(a) Complete the pseudocode algorithm:

01 FOR Count 1 TO ....................................................................................................

O2 Reading[Count] 0

03 NEXT Count

04 OUTPUT "Please enter next reading "

05 INPUT Value

06 WHILE Value <> -1 DO

07 IF Value <= 0 OR .................................................................................................

08 THEN

09 OUTPUT "Reading out of range"

10 ELSE

11 Reading[Value] .......................................................................................

12 ENDIF

13 OUTPUT "Please enter next reading "

14 ......................................................................................................................................

15 ENDWHILE

16 Count 100

17 REPEAT

18 OUTPUT "There are ", .............................................................................,


" readings of ", Count

19 Count ...................................................................................................................

20 UNTIL Count = 0
[6]

© UCLES 2022 0478/21/O/N/22


9

(b) Describe how the algorithm could be changed so that it does not output any counts of zero.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/O/N/22 [Turn over


10

3 (a) A PIN (personal identification number) is input into a banking app by the user. Before the PIN
is accepted, the following validation checks are performed:

• check 1 – each character must be a digit


• check 2 – there must be exactly four digits
• check 3 – the value of the PIN must be between 1000 and 9999 inclusive.

Describe each validation check.

Check 1 ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Check 2 ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Check 3 ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[6]

(b) The PIN can be changed by the user.

Describe how the new PIN could be verified before use.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/O/N/22


11

Question 4 starts on page 12.

© UCLES 2022 0478/21/O/N/22 [Turn over


12

4 This algorithm makes sure that there are enough fresh bread rolls available for customers to buy.

START

Stock 50
Total 0

INPUT Sold

Yes
IS Sold = OUTPUT Total
–1?

No
STOP
Stock Stock – Sold

Yes OUTPUT
IS Stock
< 20? "Add new stock"

No

Total Total + Sold Stock Stock + 50

© UCLES 2022 0478/21/O/N/22


13

(a) Complete the trace table for the algorithm using this input data:
24, 12, 6, 30, 12, 18, –1, 24

Sold Stock Total OUTPUT

[4]

(b) Identify the problem that will occur if the input data starts with a value of 70.
Explain how you would correct this problem.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/O/N/22 [Turn over


14

5 A database table, WAREHOUSE, is used to keep a record of items for sale. The table has these
fields:

• ItemCode – code to identify each type of item


• Description – brief description of each item
• Manufacturer – name of manufacturer
• Level – number in stock
• Price – price in dollars ($).

(a) State which field you would choose for the primary key. Give a reason for your choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the query-by-example grid to display only the item code and the manufacturer
where the number in stock is below 10.

Field:

Table:

Sort:

Show: o o o o
Criteria:

or:
[3]

© UCLES 2022 0478/21/O/N/22


15

BLANK PAGE

© UCLES 2022 0478/21/O/N/22


16

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 2022 0478/21/O/N/22


Cambridge IGCSE™
* 6 4 3 7 4 4 2 5 4 7 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming October/November 2022

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● Do not attempt Tasks 1, 2 and 3 in the copy of the pre-release material on page 2; these are for
information only.
● 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 50.
● 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/CB) 303988/3
© UCLES 2022 [Turn over
2

Section A

You are advised to spend no longer than 40 minutes answering this section.

Here is a copy of the pre-release material.

DO NOT attempt Tasks 1, 2 and 3 now.

Use the pre-release material and your experience from attempting the following tasks before the
examination to answer Question 1.

Pre-release Material

An organisation has a visitor car park with 20 car parking spaces numbered 1 to 20. Car park
spaces can be booked by visitors up to two weeks before the date they are needed, as long as a
space is available. Visitors request a car parking space by stating the day in the two-week period in
which it is required. They give the licence number of the car to be parked and their name. The next
available space, beginning at space 1, is allocated and the given data and booking are stored. A
system is required to record the car park bookings.
Write and test a program or programs for the visitor car park booking system to work for a static
period of two weeks:
• Your program or programs must include appropriate prompts for the entry of data. Data must
be validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All variables, constants and other identifiers must have meaningful names.
You will need to complete these three tasks. Each task must be fully tested.
Task 1 – setting up the booking system
Set up suitable data structures to store the car licence numbers and names of visitors who have
booked car parking spaces. The data structures should have sufficient capacity to store data for
each of the 20 parking spaces for a static period of two weeks. Allow a visitor to request a parking
space on any day within the two-week period by entering a number between 1 and 14, inclusive.
The system will check that there are spaces available on the day requested, and if so, will ask the
visitor to enter their name and car licence number. This data will be stored in the data structures
representing the first available parking space for the day requested. The visitor will be told the
number of their parking space.
At the end of the two-week period, allow all of the data to be deleted ready for the next two-week
period.
Task 2 – adding accessible parking spaces
The visitor car park booking system is to be re-designed to offer accessible parking. Spaces 1 to 5
are named accessible spaces. Spaces 6 to 20 are named general spaces.
Extend your program in Task 1 so that:
• when a visitor requests a parking space, they are additionally asked if they need an accessible
space
• if so, they are allocated the first available space beginning at space 1 and finishing at
space 20
• if not, they are allocated the first available space beginning at space 20 and finishing at
space 6.
The system must work so that visitors requiring accessible parking may be allocated any of the
20 spaces, but visitors who do not need accessible parking may only be allocated general spaces.
Task 3 – working out car park usage statistics
Extend the program to enable the following statistics to be counted and output on request:
• The number of accessible spaces used on any of the 14 days.
• The number of general spaces used on any of the 14 days.
• The total number of spaces used on any of the 14 days.
• The number of accessible spaces used in the whole 14-day period.
• The number of general spaces used in the whole 14-day period.
• The total number of spaces used in the whole 14-day period.
© UCLES 2022 0478/22/O/N/22
3

1 All variables, constants and other identifiers must have meaningful names.

(a) (i) Identify one constant you could have used for Task 1 and state its value.

Constant ............................................................................................................................

Value .................................................................................................................................
[2]

(ii) Identify one array you could have used in Task 1 and describe its use.

Array ..................................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[2]

(b) Describe how your program could validate the input for the day number within the two-week
period to make sure an appropriate value is entered (part of Task 1).

You must include programming statements as part of your answer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/22/O/N/22 [Turn over


4

(c) Write an algorithm to show how your program allocates a parking space if the visitor requires
accessible parking (part of Task 2), including all relevant input and output, using pseudocode,
programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2022 0478/22/O/N/22
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2022 0478/22/O/N/22 [Turn over


6

(d) Explain how your program in Task 2 could be altered so that bookings can be made for
any time over a four-week period instead of the current two-week period. Any programming
statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(e) Explain how your program records and outputs the number of accessible and general parking
spaces used for the two-week period (part of Task 3). Any programming statements used in
your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
© UCLES 2022 0478/22/O/N/22
7

Section B

2 Draw a line to connect each programming concept to the most appropriate description.

Programming concept Description

carrying out an action multiple times within a loop


structure

counting

adding together the numbers in a list of numbers


repetition

tracking the number of iterations a program has


selection performed in a loop

sequence
branching off to take a course of action depending
on the answer to a question

totalling

a set of statements to be executed in order

[4]

3 Describe the use of verification on input of data when entering a list of items in stock into a
database. Explain why verification is necessary.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

4 Describe one type of test data that must be used to test if a program accepts valid input data.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [2]

© UCLES 2022 0478/22/O/N/22 [Turn over


8

5 This pseudocode should allow 500 marks to be entered into the algorithm. If the mark is 80 or
greater it is stored in an array for higher marks. If the mark is less than 80, but greater than or
equal to 50 it is stored in an array for middle marks. The remaining marks are stored in an array
for lower marks. The results from the algorithm are displayed at the end.

01 HighList 0
02 MidList 0
03 LowList 0
04 MarksEntry 0
05 REPEAT
06 INPUT Mark
07 IF Mark >= 80
08 THEN
09 Higher[HighList] MarksEntry
10 HighList HighList + 1
11 ELSE
12 IF Mark >= 50
13 THEN
14 Middle[MidList] Mark
15 MidList MidList
16 ELSE
17 Lower[HighList] Mark
18 LowList LowList + 1
19 ENDIF
20 ENDIF
21 MarksEntry MarksEntry + 1
22 NEXT MarksEntry = 500
23 OUTPUT "You entered ", HighList, " higher marks"
24 OUTPUT "You entered ", MidList, " middle marks"
25 OUTPUT "You entered ", LowList, " lower marks"

(a) Identify the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]
© UCLES 2022 0478/22/O/N/22
9

(b) The corrected algorithm needs to be changed so that any number of marks may be entered
and the algorithm runs until the user tells it to stop.

Write the new pseudocode statements that would be needed to achieve this and state where
in the algorithm they would be placed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/22/O/N/22 [Turn over


10

6 This flowchart represents an algorithm to divide three-digit numbers into hundreds, tens and units.

The pre-defined function DIV gives the value of the result of integer division, for example
Y = 9 DIV 4 gives the value Y = 2

The pre-defined function MOD gives the value of the remainder of integer division, for example
R = 9 MOD 4 gives the value R = 1

START

Counter 0

Counter Counter + 1

Yes IS
Counter > 7?

No

INPUT
Number

IS Yes
Number < 100?

No

IS Yes
Number > 999?

No

Hundreds Number DIV 100

Temp Number MOD 100

Tens Temp DIV 10

Units Number MOD 10


STOP

OUTPUT "Hundreds: ",


Hundreds, " Tens: ",
Tens, " Units: ", Units

© UCLES 2022 0478/22/O/N/22


11

Complete the trace table for the algorithm using this input data:

97, 876, 4320, 606, 9875, 42, 124

Counter Number Hundreds Temp Tens Units OUTPUT

[5]

© UCLES 2022 0478/22/O/N/22 [Turn over


12

7 A school uses a database table, ASSESS, to keep a record of the internal assessments and the
number of candidates for each of the subjects in its curriculum.

SubjectCode SubjectName Exams Practicals Candidates


COMP Computer Science 2 1 200
INFO Information Technology 1 2 200
MATH Mathematics 3 0 350
PHYS Physics 2 1 120
CHEM Chemistry 2 1 120
BIOL Biology 2 1 200
GEOG Geography 2 0 200
HIST History 2 0 250
GEOL Geology 2 0 80
PHED Physical Education 1 2 350
FREN French 2 2 120
ENGL English 2 2 350

This database only allows the data types:


• text
• number
• currency
• Boolean.

(a) (i) State the most appropriate data type for the fields SubjectCode and Exams.

SubjectCode ......................................................................................................................

Exams ...............................................................................................................................
[1]
(ii) State one reason why the Candidates field could not be of the Boolean data type.

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2022 0478/22/O/N/22


13

(b) Show the output given by the query-by-example grid.

Field: SubjectName Practicals Candidates

Table: ASSESS ASSESS ASSESS

Sort: Ascending

Show: 3 3

Criteria: <1

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Complete the query-by-example grid to output the subjects with fewer than 150 candidates.
Display only the SubjectCode, SubjectName and Candidates fields in order of the number of
candidates from largest to smallest.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2022 0478/22/O/N/22


14

BLANK PAGE

© UCLES 2022 0478/22/O/N/22


15

BLANK PAGE

© UCLES 2022 0478/22/O/N/22


16

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 2022 0478/22/O/N/22


Cambridge IGCSE™
* 1 6 4 9 5 4 6 1 5 9 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming October/November 2022

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● Do not attempt Tasks 1, 2 and 3 in the copy of the pre-release material on page 2; these are for
information only.
● 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 50.
● 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 (LK/CB) 303980/4
© UCLES 2022 [Turn over
2

Section A
You are advised to spend no longer than 40 minutes answering this section.
Here is a copy of the pre-release material.
DO NOT attempt Tasks 1, 2 and 3 now.
Use the pre-release material and your experience from attempting the following tasks before the
examination to answer Question 1.
Pre-release Material
A program is needed for a window cleaning company to store details of the services provided to their
customers for each cleaning job.
The data stored will be used to show the customers exactly what services they are paying for
(provide an itemised bill). The data will allow the company to find out which services are used most
often and least often.
The services available to customers are:
Service Cost
basic window clean outside, only one floor, up to five windows $10.00
additional windows up to and including five $5.00
two floors 10% extra
three floors 15% extra
inside as well 25% extra
polish all windows cleaned 5% extra
special solar panel clean $20.00
The total cost of the customer’s bill is calculated in the same order as the rows of the table.
For example, a customer who has six windows over three floors is charged $10 + $5 with 15% extra,
giving a total bill of $17.25.
Write and test a program or programs for the window cleaning company:
• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All variables, constants and other identifiers must have meaningful names.
You will need to complete these three tasks. Each task must be fully tested.
Task 1 – setting up the system to store the customer and service details
Set up your program to:
• store a customer name and address in a single dimensional array at the next position
• use the array index of this position as the unique number of the itemised bill
• store any service required at the same position in the appropriate service array; use an array for
each service.
Task 2 – storing the services for a customer and displaying the itemised bill
Extend your program to:
• display the services and the cost of each one
• input and store a customer’s details and the services they require
• calculate the total cost
• display the itemised bill including the total cost and the unique number of the bill
• repeat as required.
Task 3 – providing statistics about the services
Excluding the basic window clean and the additional windows, find the most popular service and
the least popular service. For these two services, display the service name, whether it was the most
or least popular and the number of times each service was used as a percentage of the total bills
stored.

© UCLES 2022 0478/23/O/N/22


3

1 All variables, constants and other identifiers must have meaningful names.

(a) (i) Identify one constant that you could have used for Task 1.

State the value that would be assigned to the constant.

Give a reason why a constant was used rather than a variable.

Constant name ..................................................................................................................

Value .................................................................................................................................

Reason ..............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[3]

(ii) Describe the array that you set up in Task 1 to record the customer details.

Include the name, data type and sample data for the array in your description.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(b) Explain how your program allowed only two floors or three floors to be chosen but not both.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

© UCLES 2022 0478/23/O/N/22 [Turn over


4

(c) Write an algorithm for the part of Task 2 that calculates the total cost of the bill.
Assume that the customer details and services required have already been input.

Use pseudocode, programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2022 0478/23/O/N/22
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2022 0478/23/O/N/22 [Turn over
6

(d) Explain how your program completed Task 3.

Any programming statements that you include in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2022 0478/23/O/N/22


7

Section B starts on page 8.

© UCLES 2022 0478/23/O/N/22 [Turn over


8

Section B

2 An algorithm has been written to:


• set all 50 elements of the array Reading[1:50] to zero
• input values between 35 and 50 inclusive
• end the process when an input of –1 is made or 50 valid numbers have been entered
• reject all other values
• count the number of times each valid value is input
• output the number of times each value has been input, starting with the lowest value.

(a) Complete the pseudocode algorithm:

01 FOR Count 1 TO ....................................................................................................

02 Reading[Count] 0

03 NEXT Count

04 Count 1

05 OUTPUT "Please enter next reading "

06 INPUT Value

07 REPEAT

08 IF Value < 35 OR .................................................................................................

09 THEN

10 OUTPUT "Reading out of range"

11 ELSE

12 Reading[Value] .......................................................................................

13 Count = Count + 1

14 ENDIF

15 IF Count <= 50

16 THEN

17 OUTPUT "Please enter next reading "

18 .................................................................................................................................

19 ENDIF

20 UNTIL Value = -1 OR Count > 50

21 Count 35

22 REPEAT

23 OUTPUT "There are ", .....................................................................,


" readings of ", Count

24 Count ...................................................................................................................

25 UNTIL Count > 50 [6]


© UCLES 2022 0478/23/O/N/22
9

(b) Describe how the algorithm could be changed to output the number of times each value has
been input, starting with the highest value.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/23/O/N/22 [Turn over


10

3 A check digit is to be used to validate an identification number on input. The identification number
contains five digits and the check digit.
The check digit is calculated by adding up the first five digits, dividing by 10 and taking the
remainder.
For example, 5 + 1 + 2 + 4 + 3 divided by 10 gives a remainder of 5 so the six-digit
identification number would be 512435

(a) (i) Calculate the check digit for 69321

...........................................................................................................................................

..................................................................................................................................... [1]

Working space ...................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

(ii) State which of these identification numbers have incorrect check digits.

A 123455
B 691400
C 722855
D 231200

...........................................................................................................................................

..................................................................................................................................... [2]

Working space ...................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

(b) (i) Describe an input error that would not be found using this check digit.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Describe a more suitable algorithm to calculate the check digit for this identification
number.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]
© UCLES 2022 0478/23/O/N/22
11

(c) Identify two other validation checks that could be used when inputting this identification
number.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2022 0478/23/O/N/22 [Turn over


12

4 This algorithm makes sure that there are enough wheelbarrows in stock.

START

Stock 10
Total 0

INPUT Sale

Yes
Is Sale = OUTPUT Total
"N"?

No
STOP
Stock Stock – 1

Yes OUTPUT
Is Stock
< 5? "Add new stock"

No

Total Total + 1 Stock Stock + 10

© UCLES 2022 0478/23/O/N/22


13

(a) Complete the trace table for the algorithm using this input data:

“Y”, “Y”, “Y”, “Y”, “Y”, “Y”, “N”

Stock Total Sale OUTPUT

[4]

(b) Explain how you could extend the algorithm to allow for the sale of more than one wheelbarrow
at a time.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/23/O/N/22 [Turn over


14

5 A database table, MUSEUM, is used to keep a record of items in the museum. The table has
these fields:
• ItemCode – code for each type of item, for example ART0005
• Description – brief description of each item, for example gold coin
• InStore – whether the item is in store or not, for example Y
• Century – century when item made, for example 18
• Country – country of origin, for example China.

(a) Identify which field you would choose for the primary key.

State a reason for your choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the query-by-example grid to display only the description and the country of origin
for those items not in store.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2022 0478/23/O/N/22


15

BLANK PAGE

© UCLES 2022 0478/23/O/N/22


16

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 2022 0478/23/O/N/22


Cambridge IGCSE™
* 5 6 2 6 6 1 3 3 2 9 *

COMPUTER SCIENCE 0478/21


Paper 2 Algorithms, Programming and Logic October/November 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 (LK/SG) 314037/5
© UCLES 2023 [Turn over
2

1 Tick (3) one box to show which operator means less than or equal to.

A OR

B <

C <=

D >=
[1]

2 Tick (3) one box to show how a value can be passed to a procedure.

A function

B parameter

C return

D subroutine
[1]

3 Four descriptions of data and five data types are shown.

Draw one line to link each description to the most appropriate data type.
Not all data types will be used.

Description Data type

BOOLEAN
a whole number

CHAR
a single letter

INTEGER

a word or phrase
REAL

a number with two decimal places STRING

[4]

© UCLES 2023 0478/21/O/N/23


3

4 Circle the three words representing places where data may be stored.

array constant dimension input

output procedure variable


[3]

5 The first stage of the program development life cycle is analysis. Two of the tasks in analysis are
abstraction and decomposition.

(a) Describe what is meant by abstraction.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Identify three of the component parts when a problem has been decomposed at the analysis
stage.

1 ................................................................................................................................................

2 ................................................................................................................................................

3 ................................................................................................................................................
[3]

(c) Identify and describe one other stage of the program development life cycle.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/21/O/N/23 [Turn over


4

6 An algorithm has been written in pseudocode.

01 DECLARE A[1:10] : STRING


02 DECLARE T : STRING
03 DECLARE C, L : INTEGER
04 L 10
05 FOR C 1 TO L
06 OUTPUT "Please enter name "
07 INPUT A[C]
08 NEXT C
09 FOR C 1 TO L
10 FOR L 1 TO 9
11 IF A[L] > A[L + 1]
12 THEN
13 T A[L]
14 A[L] A[L + 1]
15 A[L + 1] T
16 ENDIF
17 NEXT L
18 NEXT C
19 FOR C 1 TO L
20 OUTPUT "Name ", C, " is ", A[C]
21 NEXT C

(a) State the purpose of this pseudocode algorithm.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2023 0478/21/O/N/23


5

(b) State four processes in this algorithm.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

3 ................................................................................................................................................

...................................................................................................................................................

4 ................................................................................................................................................

...................................................................................................................................................
[4]

(c) Meaningful identifiers have not been used in this algorithm.


Suggest suitable meaningful identifiers for:

The array:

A ................................................................................................................................................

The variables:

T ................................................................................................................................................

C ................................................................................................................................................

L ................................................................................................................................................
[3]

(d) State two other ways the algorithm can be made easier to understand and maintain.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2023 0478/21/O/N/23 [Turn over


6

7 Consider this logic circuit.

B X

(a) Write a logic expression for this logic circuit. Do not attempt to simplify this logic expression.

X = ............................................................................................................................................

...................................................................................................................................................
[4]

(b) Complete the truth table from the given logic circuit.

Working space
A B C X

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]

© UCLES 2023 0478/21/O/N/23


7

BLANK PAGE

© UCLES 2023 0478/21/O/N/23 [Turn over


8

8 A programmer is designing an algorithm to calculate the cost of a length of rope.


The program requirements are:
• input two values: the length of rope in metres Length and the cost of one metre Cost
• perform a validation check on the length to ensure that the value is between 0.5 and 6.0
inclusive
• calculate the price Price
• output the price rounded to two decimal places.

Use the variable names given.

(a) State the name of the validation check.

............................................................................................................................................. [1]

(b) Complete the flowchart for this algorithm.

START

STOP

[6]
© UCLES 2023 0478/21/O/N/23
9

(c) Give two different sets of test data for this algorithm and state the purpose of each set.

Set 1 .........................................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Set 2 .........................................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

(d) Complete the headings for the trace table to show a dry-run for this algorithm.
You do not need to trace the algorithm.

.................................. .................................. .................................. ..................................

[3]

(e) Describe an improvement that should be made to the requirements for this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/21/O/N/23 [Turn over


10

9 A model shop wants to set up a database to help with stock control of the model figures available
for sale. The shop wants to store this information about the model figures:
Field 1 – catalogue number, for example MD1234
Field 2 – description, for example ‘small white dog’
Field 3 – number in stock, for example 5
Field 4 – the price of each model, for example 7.40
Field 5 – if the model has already been painted, yes or no.

(a) The shop needs five fields for each record.


Give a suitable name and data type for each field.

Field 1 name .............................................................................................................................

Data type ..................................................................................................................................

Field 2 name ..............................................................................................................................

Data type ..................................................................................................................................

Field 3 name .............................................................................................................................

Data type ..................................................................................................................................

Field 4 name .............................................................................................................................

Data type ..................................................................................................................................

Field 5 name .............................................................................................................................

Data type ..................................................................................................................................


[5]

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

..................................................................................................................................... [1]

(ii) State why this field is used as the primary key.

..................................................................................................................................... [1]

(c) Structured query language (SQL) is used to query data stored in this database.
State what these SQL commands are used for.

SELECT .....................................................................................................................................

...................................................................................................................................................

FROM .........................................................................................................................................

...................................................................................................................................................

WHERE .......................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2023 0478/21/O/N/23


11

BLANK PAGE

© UCLES 2023 0478/21/O/N/23 [Turn over


12

10 Drama students put on a performance of a play for one evening. Seats in a small theatre can be
booked for this performance.

The theatre has 10 rows of 20 seats. The status of the seat bookings for the evening is held in the
two-dimensional (2D) Boolean array Evening[]

Each element contains FALSE if the seat is available and TRUE if the seat is booked.

Up to and including four seats can be booked at one time. Seats are allocated in order from those
available. A row or seat number cannot be requested.

The array Evening[] has already been set up and some data stored.

Write a program that meets the following requirements:


• counts and outputs the number of seats already booked for the evening
• allows the user to input the number of seats required
• validates the input
• checks if enough seats are available:
– if they are available
○ changes the status of the seats
○ outputs the row number and seat number for each seat booked
– if they are not available:
○ outputs a message giving the number of seats left or ‘House full’ if the theatre is fully
booked.

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.
You do not need to initialise the data in the array Evening[]
All inputs and outputs must contain suitable messages.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

© UCLES 2023 0478/21/O/N/23


13

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/21/O/N/23 [Turn over
14

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

© UCLES 2023 0478/21/O/N/23


15

BLANK PAGE

© UCLES 2023 0478/21/O/N/23


16

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


Cambridge IGCSE™
* 3 4 3 5 3 7 0 0 4 3 *

COMPUTER SCIENCE 0478/22


Paper 2 Algorithms, Programming and Logic October/November 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 (RW/SG) 314039/4
© UCLES 2023 [Turn over
2

1 Tick (✓) one box to complete the sentence.

Verification is used to make sure that a value entered

A has not changed during input.

B is an integer.

C is correct.

D is not a string.
[1]

2 A type of validation check is a length check. Another type of validation check is used to make sure
that any date entered is in the dd/mm/yyyy style:
dd means day, mm means month and yyyy means year.

(a) State the type of validation check used.

............................................................................................................................................. [1]

(b) Give one example of normal test data and one example of abnormal test data you should
use to make sure the check in part (a) is working properly.

State a reason for each of your choices of test data.

Normal ......................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Abnormal ..................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

(c) Describe how a length check could be used with the date entered.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/22/O/N/23


3

3 Four pseudocode statements and five pseudocode uses are shown.

(a) Draw one line to link each pseudocode statement to the most appropriate pseudocode use.

Not all pseudocode uses will be required.

Pseudocode statement Pseudocode use

CALL Colour(NewColour) counting

finding an average
Value (A1 + A2 + A3) / 3

totalling

Loop1 Loop1 + 1
using a conditional statement

IF Count > 7 THEN X1 0 using a procedure


[4]

(b) A one‑dimensional (1D) array called Temperatures[] has 25 elements beginning at


index 1. It holds values that range between –20 and 100 inclusive.

Write a pseudocode algorithm using a single loop to find the lowest value in this array and
output the result only once.

You do not need to declare or populate this array.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
© UCLES 2023 0478/22/O/N/23 [Turn over
4

4 An algorithm has been written in pseudocode to allow the names of 50 cities and their countries to
be entered and stored in a two‑dimensional (2D) array. The contents of the array are then output.

01 DECLARE City ARRAY[1:50, 1:2] OF BOOLEAN


02 DECLARE Count : INTEGER
03 DECLARE Out : INTEGER
04 Count 1
05 IF
06 OUTPUT "Enter the name of the city"
07 INPUT City[Count, 2]
08 OUTPUT "Enter the name of the country"
09 INPUT City[Count, 2]
10 Count Count + 1
11 UNTIL Count = 50
12 FOR Out 1 TO 1
13 OUTPUT "The city ", City[Out, 1], " is in ", City[Out, 2]
14 NEXT Out

(a) Identify the four errors in the pseudocode and suggest corrections.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2023 0478/22/O/N/23


5

(b) Describe the changes you should make to the corrected algorithm to allow the name of a
country to be input and to display only the stored cities from that country.

You do not need to rewrite the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

5 Explain how variables and constants should be used when creating and running a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

© UCLES 2023 0478/22/O/N/23 [Turn over


6

6 The flowchart represents an algorithm that performs a process on groups of values that are input.
The algorithm will fail if the first value of any group is 0.

An input of –1 will terminate the algorithm.

START

Total 0
OUTPUT
"Average is ",
Average
Count 0

INPUT OUTPUT
Value "Total is ",
Total

IS Yes
Value = Average Total / Count
0 ?

No

IS Yes
Value = STOP
–1 ?

No

Total Total + Value

Count Count + 1

© UCLES 2023 0478/22/O/N/23


7

(a) Complete the trace table for the input data:

25, 35, 3, 0, 57, 20, 25, 18, 0, –1, 307, 40, 0

Value Average Total Count OUTPUT

[5]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/22/O/N/23 [Turn over


8

7 The string operation SUBSTRING(Quote, Start, Number) returns a string from Quote
beginning at position Start that is Number characters long. The first character in Quote is in
position 1.

Write pseudocode statements to:


• store the string "Learning Never Exhausts The Mind" in Quote
• extract and display the words "The Mind" from the string
• output the original string in lower case.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [5]

8 Explain why a programmer would use procedures and parameters when writing a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [4]

© UCLES 2023 0478/22/O/N/23


9

9 Consider the logic expression:

Z = (A NAND B) OR NOT (B XOR C)

(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.

B Z

[4]

(b) Complete the truth table from the given logic expression.

Working space
A B C 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]

© UCLES 2023 0478/22/O/N/23 [Turn over


10

10 A database table called Horses stores details about the horses kept at a horse sanctuary.

Code Breed BreedOrigin Gender Age Arrived


H002 Arabian Saudi Arabia M 5 28/09/2022
H004 Percheron France M 5 30/10/2022
H010 Friesian Netherlands M 6 15/11/2022
H011 Fjord Norway F 4 17/11/2022
H012 Clydesdale Scotland M 10 18/11/2022
H015 Arabian Saudi Arabia F 5 15/12/2022
H016 Arabian Saudi Arabia F 5 15/12/2022
H017 Clydesdale Scotland F 4 16/01/2023
H019 Percheron France M 3 16/01/2023
H025 Percheron France M 7 16/01/2023
H026 Clydesdale Scotland F 9 20/01/2023
H030 Clydesdale Scotland M 12 20/01/2023
H032 Fjord Norway M 3 24/03/2023
H033 Arabian Saudi Arabia F 15 27/04/2023
H034 Clydesdale Scotland F 4 14/06/2023
H035 Fjord Norway M 7 15/06/2023
H036 Friesian Netherlands F 15 20/07/2023
H037 Friesian Netherlands M 12 20/07/2023

(a) State the number of records in this database table.

............................................................................................................................................. [1]

(b) Give the name of the field that is most suitable to be the primary key.

State the reason for this choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2023 0478/22/O/N/23


11

(c) The database only allows the data types:


• Boolean
• character
• date/time
• integer
• real
• text.

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

Field Data type


Breed

Gender

Age

Arrived
[2]

(d) Complete the structured query language (SQL) to return the code and breed of all the horses
whose breed originated in Scotland.

......................................... Code, Breed,

FROM .........................................

WHERE ......................................... = "Scotland";


[3]

© UCLES 2023 0478/22/O/N/23 [Turn over


12

11 A wood flooring company stores the names of up to 100 customers in a one‑dimensional (1D) array
Customers[]. A two‑dimensional (2D) array Quotations[] stores details of each customer’s
quotation:
• length of room (one decimal place)
• width of room (one decimal place)
• area of wood required (rounded up to next whole number)
• choice of wood index (whole number)
• price of wood required in dollars (two decimal places).

The floor measurements (room length and room width) are taken in metres. All floors are rectangles
and room measurements must be between 1.5 and 10.0 inclusive.

The index of any customer’s data is the same in both arrays. For example, a customer named in
index 4 of Customers[] corresponds to the data in index 4 of Quotations[]

The wood choices available are:

Index Wood type Price per square metre ($)


1 Laminate 29.99
2 Pine 39.99
3 Oak 54.99

The data are stored in two 1D arrays named WoodType[] and Price[]. The index of the wood
type and price in their arrays share the same index number.

Write a program that meets the following requirements:


• input a new customer’s name, room length and room width
• check that each measurement is valid
• output an error message and require the measurement to be re‑entered until it is valid
• calculate the area of the room by multiplying together the length of the room and the width of
the room
• input the choice of wood and find its price per square metre
• calculate the price of the wood needed
• store all data in the relevant array
• output the customer’s quotation to include: the name of the customer, the choice of wood and
the calculated price of the wood required
• continue to accept the next customer.

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.

You will need to initialise WoodType[] and Price[]

All inputs and outputs must contain suitable messages.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/22/O/N/23
13

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/22/O/N/23 [Turn over
14

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

© UCLES 2023 0478/22/O/N/23


15

BLANK PAGE

© UCLES 2023 0478/22/O/N/23


16

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/22/O/N/23


Cambridge IGCSE™
* 2 5 0 4 8 4 8 1 1 1 *

COMPUTER SCIENCE 0478/23


Paper 2 Algorithms, Programming and Logic October/November 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/CT) 313523/5
© UCLES 2023 [Turn over
2

1 Tick (3) one box to show which term is an example of a verification check.

A Double entry check

B Format check

C Length check

D Presence check
[1]

2 Tick (3) one box to show which library routine returns the remainder of a division.

A DIV

B MOD

C RANDOM

D ROUND
[1]

© UCLES 2023 0478/23/O/N/23


3

3 (a) Four pseudocode descriptions and five pseudocode keywords are shown.

Draw one line to link each pseudocode description to the most appropriate pseudocode
keyword. Not all pseudocode keywords will be used.

Pseudocode description Pseudocode keyword

stores data in a file OUTPUT

WRITE
retrieves data from a file

READ

displays data on a screen


OPEN

enters data from a keyboard INPUT

[4]

(b) Give two reasons for storing data in a file.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2023 0478/23/O/N/23 [Turn over


4

4 A programmer is writing a data entry program for booking theatre seats.


The programmer needs the program to accept only whole numbers that are greater than or equal
to one and less than or equal to six.

(a) Give the names of two validation checks that are required for this program.

1 ................................................................................................................................................

2 ................................................................................................................................................
[2]

(b) Complete this pseudocode to perform your two validation checks, using your answers given
in (a):

OUTPUT "Please enter the number of seats you want to book "

INPUT Seats

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[5]

(c) Give one item of test data to use when testing this program.
State the reason for your choice of test data.

Test data ...................................................................................................................................

Reason for choice .....................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2023 0478/23/O/N/23


5

BLANK PAGE

© UCLES 2023 0478/23/O/N/23 [Turn over


6

5 An algorithm has been written in pseudocode to check if a new password is in a list of previously
used passwords OldList[]
If the password is not found, the new password will be stored at the end of the list to replace
"XXXX" already stored there.

01 OUTPUT "Enter your new password "


02 INPUT NewPassword
03 Posn 1
04 Found FALSE
05 REPEAT
06 IF Password = OldList[Posn]
07 THEN
08 Found TRUE
09 ELSE Posn Posn + 1
10 ENDIF
11 UNTIL Found AND OldList[Posn] = "XXXX"
12 IF Found
13 THEN
14 OUTPUT "Password has been used before"
15 ELSE
16 INPUT "New password accepted"
17 OldList[Posn] NewPassword
18 ENDIF

(a) Identify the three errors in the pseudocode and suggest corrections.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2023 0478/23/O/N/23


7

(b) Complete this flowchart for the corrected algorithm:

START

STOP

[6]

© UCLES 2023 0478/23/O/N/23 [Turn over


8

6 There are three descriptions of logic gates. Each logic gate has two inputs A and B with one
output X.
Identify each logic gate.
Complete a truth table for each logic gate.

(a) The only time the output is 1 is when both inputs are 1.
A B X
Logic gate ...............................................
0 0
Complete the truth table for this description.
0 1

1 0

1 1

[2]

(b) The output is 1 when both inputs are different.


A B X
Logic gate ...............................................
0 0
Complete the truth table for this description.
0 1

1 0

1 1

[2]

(c) The only time the output is 1 is when both inputs are 0.
A B X
Logic gate ...............................................
0 0
Complete the truth table for this description.
0 1

1 0

1 1

[2]

© UCLES 2023 0478/23/O/N/23


9

(d) Consider this logic expression:

X = (NOT A OR NOT B) OR NOT C

Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two
inputs. Do not attempt to simplify this logic expression.

B X

[5]

7 A program uses both local variables and global variables.

Describe two differences between local variables and global variables.

Difference 1 ......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Difference 2 ......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2023 0478/23/O/N/23 [Turn over


10

8 This is an algorithm to find if a batch of parts has been manufactured successfully.

START

Accept 0
Reject 0

INPUT PartOK

No
IS PartOK Reject Reject + 1
= 'Y'?
Yes

Accept Accept + 1

No IS Accept
= 10 ?

Yes

Yes
IS Reject Error Reject/Accept * 100
> 1?

No
OUTPUT
"Too many rejected ",
OUTPUT Error, "% error"
"Success"

STOP

© UCLES 2023 0478/23/O/N/23


11

(a) Complete the trace table using this data:


Y, Y, Y, N, Y, Y, Y, Y, N, Y, Y, Y, Y

Accept Reject PartOK Error OUTPUT

[5]

(b) Describe how the algorithm should be changed to accept ‘Y’ or ‘y’ for a successfully
manufactured part.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2023 0478/23/O/N/23 [Turn over


12

9 A sanctuary for pheasants has set up a new database table called PheasantList to store details
of the different species of bird at the sanctuary. Part of this table is given, showing: species,
description, number of birds at the sanctuary, if the birds are breeding or not, and number of
young born this year.

Species Description NumberBirds Breeding Young


Edwards blue-black with white tail 5 Yes 0
Japanese green dark green with pale grey tail 2 Yes 2
Reeves golden, white and red scaled plumage 4 Yes 1
Crawfords Kalij glossy blue-black plumage 4 No 0
Crested fireback blue-black with black tail 3 No 0
True silver white laced top half and black lower half 7 Yes 1
Siamese fireback grey plumage with crimson legs and feet 5 No 0
Mikado iridescent plumage with white striped wings 3 Yes 4
Red junglefowl many colours 2 Yes 0
Himalayan monal many colours with metallic green crest 3 Yes 2
White eared white with ear tufts 5 Yes 3
Brown eared brown with ear tufts 9 Yes 1
Ring necked long tail with white ring neck 2 Yes 2
Golden rainbow coloured 3 Yes 4

(a) State the number of records and fields in this part of the database table.

Records .....................................................................................................................................

Fields .........................................................................................................................................
[2]

(b) (i) Give the name of a field that could be used for the primary key.

..................................................................................................................................... [1]

(ii) Explain why the sanctuary might decide not to use the field in (b)(i) as the primary key.

...........................................................................................................................................

..................................................................................................................................... [1]

(iii) A new field SpeciesID is added to the database table.


This field contains a six-character code, for example Ph0001.

Give a reason why this field would be a better primary key.

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2023 0478/23/O/N/23


13

(c) Write the output that would be given by this structured query language (SQL) statement:

SELECT Species, Description

FROM PheasantList

WHERE NumberBirds > 6;

...................................................................................................................................................

............................................................................................................................................. [2]

(d) Complete this SQL statement to display all the species of pheasant where the birds are
breeding and there were no young born this year:

SELECT ....................................................................................................................................

FROM ........................................................................................................................................

WHERE ......................................................................................................................................

.............................................................................................................................................. ;
[4]

© UCLES 2023 0478/23/O/N/23 [Turn over


14

10 A weather station takes temperature readings once an hour for a week. These temperatures are
stored in a two-dimensional (2D) array Temperatures[]
Each column contains 24 readings for a single day. The first temperature is recorded at 00:00 and
the final temperature at 23:00. There are seven columns, one for each day of the week, starting
with Monday and ending with Sunday.

The variables MaxDay, MinDay and AvDay are used to store the maximum, minimum, and
average temperatures for a day. The variables MaxWeek, MinWeek and AvWeek are used to store
the maximum, minimum, and average temperatures for the week.

The array has already been set up and the data stored.

Write a program that meets the following requirements:


• finds the maximum and minimum temperatures for each day
• calculates the average temperature for each day
• outputs for each day:
– name of the day, for example Monday
– maximum temperature
– minimum temperature
– average temperature
• finds the maximum and minimum temperatures for the week
• calculates the average temperature for the week
• outputs:
– maximum temperature for the week
– minimum temperature for the week
– average temperature for the week.

All temperatures output must be rounded to two decimal places.

You must use pseudocode or program code and add comments to explain how your code works.
All inputs and outputs must contain suitable messages.

You do not need to declare any arrays or variables; you may assume that this has already been
done.
You do not need to initialise the data in the array Temperatures[]

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/23/O/N/23
15

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/23/O/N/23 [Turn over
16

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

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/O/N/23

You might also like