Programming – IGCSE Computer Science (0478)

282 questions · page 8 of 19

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
106
0478/21/O/N/23 · Question 10Oct/Nov 2023Paper 2115 marks
Loading question…
Question text

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

107
0478/22/O/N/23 · Question 1Oct/Nov 2023Paper 221 marks
Loading question…
Question text

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]

108
0478/22/O/N/23 · Question 3Oct/Nov 2023Paper 228 marks
Loading question…
Question text

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 use
Pseudocode statement
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]

Advertisement
109
0478/22/O/N/23 · Question 4Oct/Nov 2023Paper 229 marks
Loading question…
Question text

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
1
04
Count
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]
Count + 1
10
Count
11
UNTIL Count = 50
1 TO 1
12
FOR Out
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]
(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.
…
…
…
…
…
…
…
…
…
…

110
0478/22/O/N/23 · Question 5Oct/Nov 2023Paper 223 marks
Loading question…
Question text

5
Explain how variables and constants should be used when creating and running a program.
…
…
…
…
…
… [3]

111
0478/22/O/N/23 · Question 7Oct/Nov 2023Paper 225 marks
Loading question…
Question text

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]

112
0478/22/O/N/23 · Question 8Oct/Nov 2023Paper 224 marks
Loading question…
Question text

8
Explain why a programmer would use procedures and parameters when writing a program.
…
…
…
…
…
…
…
… [4]

113
0478/22/O/N/23 · Question 11Oct/Nov 2023Paper 2215 marks
Loading question…
Question text

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

Advertisement
114
0478/23/O/N/23 · Question 2Oct/Nov 2023Paper 231 marks
Loading question…
Question text

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]

115
0478/23/O/N/23 · Question 5Oct/Nov 2023Paper 239 marks
Loading question…
Question text

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
1
03
Posn
FALSE
04
Found
05
REPEAT
06
IF Password = OldList[Posn]
07
THEN
TRUE
08
Found
Posn + 1
09
ELSE Posn
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"
NewPassword
17
OldList[Posn]
18
ENDIF
(a) Identify the three errors in the pseudocode and suggest corrections.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
[3]
(b) Complete this flowchart for the corrected algorithm:
START
STOP
[6]

116
0478/23/O/N/23 · Question 7Oct/Nov 2023Paper 234 marks
Loading question…
Question text

7
A program uses both local variables and global variables.
Describe two differences between local variables and global variables.
Difference 1 …
…
…
…
Difference 2 …
…
…
…
[4]

117
0478/23/O/N/23 · Question 10Oct/Nov 2023Paper 2315 marks
Loading question…
Question text

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[]
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

118
0478/11/M/J/23 · Question 7May/June 2023Paper 114 marks
Loading question…
Question text

7
A programmer uses a low‑level language to write a computer program for a vending machine.
(a) Describe what is meant by a low‑level language.
…
…
…
… [2]
(b) Give two reasons why the programmer would choose to write the computer program in a
low‑level language instead of a high‑level language.
1 …
…
2 …
…
[2]

Advertisement
119
0478/11/M/J/23 · Question 9May/June 2023Paper 115 marks
Loading question…
Question text

9
A company uses robots in its factory to manufacture large pieces of furniture.
(a) One characteristic of a robot is that it is programmable.
State two other characteristics of a robot.
1 …
…
2 …
…
[2]
(b) Give two advantages to company employees of using robots to manufacture large pieces of
furniture.
1 …
…
2 …
…
[2]
(c) Give one disadvantage to the company’s owners of using robots to manufacture large pieces
of furniture.
…
… [1]

120
0478/21/M/J/23 · Question 2May/June 2023Paper 211 marks
Loading question…
Question text

Tick ( ü ) one box to show the name of the data structure used to store a collection of data of the
2
same data type.
A
Array
B
Constant
C
Function
D
Variable
[1]

Advertisement