Programming – IGCSE Computer Science (0478)

282 questions · page 7 of 19

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
91
0478/23/M/J/24 · Question 4May/June 2024Paper 2312 marks
Loading question…
Question text

4
This pseudocode algorithm is intended to allow data for up to 50 people to be entered and stored
in a two-dimensional (2D) array. The data is their last name, first name and the city in which they
live.
01
DECLARE
People : ARRAY[1:50, 1:3] OF REAL
02
DECLARE
Count : INTEGER
03
DECLARE
Response : CHAR
04
DECLARE
Continue : BOOLEAN
05
FOR I
1 TO 50
06
FOR
J
1 TO 3
07
People[I, J]
""
08
NEXT J
09
NEXT I
10
Count
100
11
Continue
TRUE
12
CASE OF
13
OUTPUT "Enter the last name"
14
INPUT People[Count, 1]
15
OUTPUT "Enter the first name"
16
INPUT People[Count, 2]
17
OUTPUT "Enter the city"
18
INPUT People[Count, 3]
19
OUTPUT "Do you want to enter another name (Y or N)?"
20
INPUT Response
21
IF Response = 'N'
22
THEN
23
Continue
FALSE
24
ELSE
25
Count
Count + 1
26
ENDIF
27
UNTIL NOT Count
(a) Identify the line numbers of the four errors in the pseudocode and suggest corrections.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
Error 4 line number …
Correction …
…
[4]
(b) Write the pseudocode that you could add to the end of this algorithm to output the contents of
the array. Make sure that the output ends when the data in the array ends.
…
…
…
…
…
…
…
… [4]
(c) Explain how you could alter the orig

92
0478/23/M/J/24 · Question 5May/June 2024Paper 2313 marks
Loading question…
Question text

5
The flowchart represents an algorithm.
START
L
0
S
10000
T
0
A
0
INPUT
Limit
Count
1
INPUT
Value
IS
IS
No
No
Value < S
Value > L
?
?
Yes
Yes
L
Value
S
Value
T
T + Value
IS
No
Count >
Count
Count + 1
Limit ?
Yes
T / Limit
A
OUTPUT "L = ", L, " S = ",
S, " T = ", T, " A = ", A
STOP
(a) Complete the trace table for the input data:
10, 30, 18, 8, 25, 12, 17, 2, 50, 15, 5
L
S
T
A
Limit
Count
Value
OUTPUT
[6]
(b) Outline the purpose of the algorithm.
…
…
…
… [2]
(c) Explain why the identifiers L, S, T and A may not be appropriate to use as identifiers and how
they could be improved.
…
…
…
…
…
… [3]
(d) State a more appropriate identifier for each of the variables L, S, T and A
Original identifier
Improved identifier
L
S
T
A
[2]

93
0478/23/M/J/24 · Question 7May/June 2024Paper 237 marks
Loading question…
Question text

(a) The string operation SUBSTRING(FullText, X, Y) returns a string from FullText
7
beginning at position X that is Y characters long. The first character in FullText is in
position 1.
Write the pseudocode statements to:
•
store the string “IGCSE Computer Science at Cambridge” in FullText
•
extract and display the words “Computer Science” from the string and store it in a suitable
variable
•
output the original string in upper case.
…
…
…
…
…
… [4]
(b) Write the pseudocode statements to:
•
store the content of the variable you created in part (a) to a text file named
"Subjects.txt"
•
close the text file at the end of the algorithm.
…
…
…
…
…
… [3]

Advertisement
94
0478/23/M/J/24 · Question 9May/June 2024Paper 2315 marks
Loading question…
Question text

A one-dimensional (1D) array Teams[] contains the names of 10 football teams in a local league.
9
A two-dimensional (2D) array Results[] stores, for each team, the total number of:
•
games won
•
games drawn
•
games lost
•
points.
The position of any team’s data is the same in both arrays. For example the data in index 3 of
Results[] belongs to the team in index 3 of Teams[]
The array data will be used to find the current leader of the league.
The variable Played stores the number of games played by each team. Each team plays the
same number of games.
Write a program that meets the following requirements:
•
allows the number of games played to be input and stored, with a maximum of 18 games
•
allows the names of the teams to be input and stored
•
allows the number of games won, drawn and lost to be input and stored for each team
•
validates the number of games played and the number of games won, drawn or lost against
the number of games played
•
calculates and stores the number of points for each team using three points for a win and one
point for a draw; there are no points for a loss
•
sorts the array Results[] into descending order of number of points, ensuring the
corresponding parallel array Teams[] is kept in the same order
•
determines how many teams have the highest number of points
•
outputs the name(s) of the winning team(s) along with the number of points achieved.
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.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

95
0478/22/F/M/24 · Question 2Feb/March 2024Paper 228 marks
Loading question…
Question text

2
(a) Four test data types and five descriptions are shown.
Draw one line to link each test data type to its most appropriate description.
Test data type
Description
abnormal
a value that is accepted
a value that is the highest or lowest value to be accepted and
the corresponding lowest or highest value to be rejected
boundary
a value that is the highest or lowest value to be rejected
extreme
a value that is rejected
a value that is the highest or lowest value to
be accepted
normal
[4]
(b) An algorithm has been written to test if an integer that is input is in the range 5 to 10 inclusive.
Identify an example of suitable test data for each test data type.
Abnormal …
…
Boundary …
…
Extreme …
…
Normal …
…
[4]

96
0478/22/F/M/24 · Question 4Feb/March 2024Paper 223 marks
Loading question…
Question text

4
Identify three data types used in programming.
1 …
2 …
3 …
[3]

97
0478/22/F/M/24 · Question 6Feb/March 2024Paper 224 marks
Loading question…
Question text

6
Describe two types of iteration that a programmer can use whilst writing a program.
…
…
…
…
…
…
…
… [4]

98
0478/22/F/M/24 · Question 10Feb/March 2024Paper 226 marks
Loading question…
Question text

10 A programmer has written a program that will be maintained by another programmer.
Explain how the program can be written to make sure it can be easily maintained by the other
programmer.
…
…
…
…
…
…
…
…
…
…
…
… [6]

Advertisement
99
0478/22/F/M/24 · Question 11Feb/March 2024Paper 2215 marks
Loading question…
Question text

11
Students in a class are recording the amount of time in minutes spent in front of a screen for each
day of the week.
The one-dimensional (1D) array StudentName[] contains the names of the students in the class.
The two-dimensional (2D) array ScreenTime[] is used to input the number of minutes on each
day spent in front of a screen.
The position of each student’s data in the two arrays is the same. For example, the student stored
at index 10 in StudentName[] and ScreenTime[] is the same.
The variable ClassSize contains the number of students in the class.
Write a program that meets these requirements:
•
allows all the students to enter their daily minutes of screen times for the past week
•
calculates the total number of minutes of screen time for each student in the week
•
counts, for each student, the number of days with more than 300 minutes of screen time
•
calculates the average weekly minutes of screen time for the whole class
•
finds the student with the lowest weekly minutes of screen time
•
outputs for each student:
–
name
–
total week’s screen time in hours and minutes
–
number of days with more than 300 minutes of screen time
•
outputs the average weekly minutes of screen time for the whole class
•
outputs the name of the student with the lowest weekly screen time.
You must use pseudocode or program code and add comments to explain how your code works.
All inputs and outputs must contain suitable messages.
Assume that the array StudentName[] and the variable ClassSize already contain the
required data.
You do not need to declare any arrays or variables; you may assume that this has already been
done.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

100
0478/11/O/N/23 · Question 3Oct/Nov 2023Paper 114 marks
Loading question…
Question text

3
The table contains four descriptions about a computer system.
Complete the table by writing the correct term for each description.
Term
Description
A collective term for the physical components
… of the computer system.
A type of software that provides services
that the user requires and allows the user to
…
perform tasks on the computer.
A type of software that manages the
main functions of the computer, including
…
managing files and managing memory.
A type of software that is stored in the
read only memory (ROM). It includes the
… basic input output system (BIOS) and the
bootloader.
[4]

101
0478/21/O/N/23 · Question 1Oct/Nov 2023Paper 211 marks
Loading question…
Question text

1
Tick (3) one box to show which operator means less than or equal to.
A
OR
B
<
C
<=
D
>=
[1]

102
0478/21/O/N/23 · Question 2Oct/Nov 2023Paper 211 marks
Loading question…
Question text

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]

103
0478/21/O/N/23 · Question 3Oct/Nov 2023Paper 214 marks
Loading question…
Question text

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]

Advertisement
104
0478/21/O/N/23 · Question 4Oct/Nov 2023Paper 213 marks
Loading question…
Question text

4
Circle the three words representing places where data may be stored.
array
constant
dimension
input
output
procedure
variable
[3]

105
0478/21/O/N/23 · Question 6Oct/Nov 2023Paper 2110 marks
Loading question…
Question text

6
An algorithm has been written in pseudocode.
01 DECLARE A[1:10] : STRING
02 DECLARE T : STRING
03 DECLARE C, L : INTEGER
10
04 L
1 TO L
05 FOR C
06
OUTPUT "Please enter name "
07
INPUT A[C]
08 NEXT C
1 TO L
09 FOR C
1 TO 9
10
FOR L
11
IF A[L] > A[L + 1]
12
THEN
A[L]
13
T
A[L + 1]
14
A[L]
T
15
A[L + 1]
16
ENDIF
17
NEXT L
18 NEXT C
1 TO L
19 FOR C
20
OUTPUT "Name ", C, " is ", A[C]
21 NEXT C
(a) State the purpose of this pseudocode algorithm.
…
… [1]
(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]

Advertisement