Programming – IGCSE Computer Science (0478)

270 questions · page 8 of 18 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
106
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]

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

108
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]

Advertisement
109
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]

110
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]

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

112
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]

113
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]

Advertisement
114
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]

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

116
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]

117
0478/21/M/J/23 · Question 4May/June 2023Paper 214 marks
Loading question…
Question text

4
Explain the purpose of the library routines DIV and ROUND
DIV …
…
…
…
ROUND …
…
…
…
[4]

118
0478/21/M/J/23 · Question 5May/June 2023Paper 218 marks
Loading question…
Question text

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.
←
1
01
Exit
02
WHILE Exit <> 0 DO
03
INPUT Number
04
IF Number < 0
05
THEN
←
Total + Number
06
Total
07
ELSE
08
IF Number = 0
09
THEN
←
1
10
Exit
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]
(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]

Advertisement
119
0478/21/M/J/23 · Question 6May/June 2023Paper 214 marks
Loading question…
Question text

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]

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

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
IS
No
Yes
Choice =
STOP
'Y' ?
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]
(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]

Advertisement