Programming – IGCSE Computer Science (0478)

270 questions · page 5 of 18 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
61
0478/23/M/J/25 · Question 8May/June 2025Paper 2315 marks
Loading question…
Question text

8
A collector needs a video library system for a collection of videos stored on 4K Blu-ray discs,
standard Blu-ray discs, DVD, or as digital downloads.
The two-dimensional (2D) array Video[] is used to store, for each video item, the title, the format
of the video (4K Blu-ray disc, standard Blu-ray disc, DVD, or digital download), the year it was
released stored as a string and a storage code to represent where the video can be found in the
collection, for example:
Video[1,1]
is
"Macbeth"
Video[1,2]
is
"digital download"
Video[1,3]
is
"2015"
Video[1,4]
is
"DG276"
The two-dimensional (2D) array Results[] is used to store the results of a search to find a
specific video. The search uses the video title, and if the video is found, its data is copied from the
array Video[] to the array Results[]. The search continues and if other videos with the same
title are found, this data is also copied to the array Results[]. The search ends when the end of
the data is reached.
Write a program that meets the following requirements:
•
The video library array needs to be initialised with the null string (""), allowing for up to
10 000 records. The array Results[] must be initialised before every search with the null
string and must be able to hold up to 20 search results with the same title.
•
Create a menu to add a new video to the library to search for an existing video by title, or to
stop, with validation of the input.
•
When the user enters a new video, the following data is stored in the first available location of
the relevant array:
o video title
o format (4K Blu-ray disc, standard Blu-ray disc, DVD, digital download)
o year of release as string
o storage code.
•
Allow input of data for another video if required.
•
When searching for an existing video, if a match is found, transfer all the data for that video
into the array Results[], and continue to search until all videos with the same title have
been found.
•
Output the results from the array Results[]
•
If the video title is not found, output a suitable message.
•
The system returns to the menu after completing the input or the output, until the user
chooses to stop.
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.
…
…
…
…
ĬÑĊ®Ġ´íÈõÏĪÅĊßú¸Ā×
,
,
…
…
…
…
…
…
…

62
0478/22/F/M/25 · Question 2Feb/March 2025Paper 221 marks
Loading question…
Question text

2
Tick (✓) one box to complete this sentence.
The pseudocode to store a hotel name held in the variable Name to a text file is
A
READFILE Hotels.txt, Name
B
WRITEFILE Hotels.txt, Name
C
WRITEFILE Name, Hotels.txt
D
STOREFILE Hotels.txt, Name
[1]

63
0478/22/F/M/25 · Question 5Feb/March 2025Paper 226 marks
Loading question…
Question text

5
A program is written to only accept data that contains more than 9 characters. The program needs
to be tested. The table, when completed, shows appropriate test data that matches the type of test
data and the purpose of the test data.
Complete the table by inserting the missing information.
Test data
Type of test data
Purpose of test data
…
ABC
…
…
Boundary
…
to make sure that the program accepts data
that is an appropriate length
[6]

Advertisement
64
0478/22/F/M/25 · Question 6Feb/March 2025Paper 2211 marks
Loading question…
Question text

6
This pseudocode algorithm is intended to allow 1000 positive integers to be input and stored in
a one-dimensional (1D) array. The integers are added together as they are input and the highest
value is identified. At the end of the algorithm, the highest number, the total and the average of the
numbers are output.
01
DECLARE Numbers : ARRAY[1:1000] OF INTEGER
02
DECLARE Highest : STRING
03
DECLARE Count : INTEGER
04
DECLARE Total : INTEGER
←
1500
05
Highest
←
0
06
Total
←
1 TO 1000
07
FOR Count
08
INPUT Numbers[Count]
←
Total + Count
09
Total
10
IF Numbers[Count] > Total
11
THEN
←
Numbers[Count]
12
Highest
13
ENDIF
14
NEXT Count
15
OUTPUT "The highest number is ", Highest
16
OUTPUT "The total is ", Total
17
OUTPUT "The average is ", Average / 1000
(a) Identify the line numbers of five errors in the pseudocode and suggest a correction for each
error.
Error 1 line number …
Correction …
…
ĬÍĊ®Ġ´íÈõÏĪÅĊÝû¸Ā×
,
,
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
Error 4 line number …
Correction …
…
Error 5 line number …
Correction …
…
[5]
(b) Write the pseudocode statement to output the average of the numbers, rounded to two
decimal places.
…
… [2]
(c) Explain how you could change the corrected algorithm so that it also finds the smallest
number that was input and outputs its value at the end.
Any code used must be fully explained.
…
…
…

65
0478/22/F/M/25 · Question 7Feb/March 2025Paper 2210 marks
Loading question…
Question text

7
This flowchart represents an algorithm.
START
OUTPUT
"Continue?"
INPUT Answer
No
Yes
IS Answer =
'Y' ?
INPUT
Value1
STOP
INPUT
Operator
INPUT
Yes
IS Operator =
Value2
'A' ?
OUTPUT
Value1 +
No
Value2
Yes
IS Operator =
'S' ?
OUTPUT
Value1 –
No
Value2
Yes
No
IS Operator =
'M' ?
OUTPUT
OUTPUT
Value1 *
Value1 /
Value2
Value2
ĬÑĊ®Ġ´íÈõÏĪÅĊàùµþ×
,
,
(a) Complete the trace table for the input data:
Y, 7, S, 9, Y, 5, M, 12, Y, 25, D, 5, N, 10, A, 6
Answer
Value1
Operator
Value2
OUTPUT
[5]
(b) State the purpose of the algorithm on page 6.
… [1]
(c) There are problems with the given algorithm. If the lower-case letter ‘y’ is entered for Answer,
the algorithm stops and if a lower-case letter is entered for Operator, the algorithm gives an
incorrect output.
(i)
Explain how you would change the algorithm to prevent the problems described.
…
…
…
…
…
… [3]
(ii)
Identify one more error related to inputs when the algorithm is run.
…
… [1]
ĬÓĊ®Ġ´íÈõÏĪÅĊàûµþ×

66
0478/22/F/M/25 · Question 10Feb/March 2025Paper 2215 marks
Loading question…
Question text

10 A sports club uses a six-character alphanumeric membership code to identify each member of the
club.
The one-dimensional (1D) array MemberID[] is used to store the unique membership codes for
club members.
The two-dimensional (2D) array Name[] is used to store the names of the club members. The first
and last name of each member will be stored in separate array elements.
The system can store details for a maximum of 1000 members.
The position of any member’s data is the same in both arrays. For example, the data in index 2 of
MemberID[] belongs to the member in index 2 of Name[]
The variable NewID is used to input a new membership code.
Write a program that meets the following requirements:
•
Provide a menu that offers the choices: inputting a new member, outputting a list of
membership codes and first and last names, or stopping.
•
Input and validate a response to the menu.
•
When inputting a new member, input a new membership code and check that it contains six
characters:
○ If the new code is six characters, check it against all the previously stored membership
codes to make sure it is unique.
○ If the code is not unique, a new code must be entered and checked.
○ If the code is unique, it is stored in the first available space in the appropriate array
and the new member is required to enter their first name and last name, which are also
stored in the corresponding location of the appropriate array.
•
When outputting a list of membership codes and names, output for each member: their
membership code, first name and last name.
•
The program will continue until the stop option on the menu is selected.
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; assume this has already been
done.
You do not need to initialise the data in the arrays.
You do need to initialise any variables or constants used if appropriate.
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
…
ĬÑĊ®Ġ´íÈõÏĪÅĊÝù·Ā×
,
,
…
…
…
…
…
…

67
0478/21/O/N/24 · Question 3Oct/Nov 2024Paper 214 marks
Loading question…
Question text

3
Four operators and three types of operator are shown.
Draw one or more lines from each operator to its correct operator type.
Operator
Operator type
>=
Boolean
AND
Arithmetic
DIV
Logical
+
[4]
ĬÍĊ®Ġ´íÈõÏĪÅĊßú¸þ×

68
0478/21/O/N/24 · Question 6Oct/Nov 2024Paper 219 marks
Loading question…
Question text

6
An incomplete algorithm has been written in pseudocode to count the number of zeros stored in
an array and total the non-zero values.
01 DECLARE A[1:50] : INTEGER
02 DECLARE C : INTEGER
03 DECLARE I : INTEGER
04 DECLARE T : INTEGER
←
05 I
0
06 …
←
07 FOR C
1 TO 50
08
IF A[C] …
09
THEN
←
10
T
T + 1
11
ELSE
←
12
I
I + A[C]
13
ENDIF
14 …
(a) Complete the given pseudocode algorithm.
[3]
(b) Write the pseudocode to display, with suitable messages, the number of zeros stored in the
array and the total of the non-zero values.
…
…
…
…
…
… [3]
(c) Meaningful identifiers have not been used in the algorithm.
Suggest suitable meaningful identifiers for:
The array:
A …
The variables:
T …
C …
I …
[3]
ĬÍĊ®Ġ´íÈõÏĪÅĊÝú¸Ā×

Advertisement
69
0478/21/O/N/24 · Question 8Oct/Nov 2024Paper 2111 marks
Loading question…
Question text

8
A programmer is designing a program to check the length of a password and to check if the
password input is the same as the stored password.
The program requirements are:
•
input the password, Password
•
check if there are at least 8 characters in the password
•
check that the password is not the same as the stored password OldPass
•
output ‘accepted’ if both tests are completed successfully
•
otherwise, output ‘rejected’.
Use the variable names given.
(a) Complete the flowchart for the program.
START
STOP
[6]
ĬÑĊ®Ġ´íÈõÏĪÅĊàüµþ×
,
,
(b) The accepted password, Password, is to be written to the file MyPassword.txt
Write pseudocode to:
•
open the file
•
write the accepted password to the file
•
close the file.
…
…
…
…
… [3]
(c) Explain why the accepted password needs to be stored in a file.
…
…
…
… [2]
ĬÓĊ®Ġ´íÈõÏĪÅĊàúµþ×

70
0478/21/O/N/24 · Question 9Oct/Nov 2024Paper 218 marks
Loading question…
Question text

9
An algorithm has been written in pseudocode to check if a temperature is in a given range.
The temperature values used in the algorithm are correct.
01 REPEAT
02
OUTPUT "Please enter temperature "
03
INPUT Temp
04
IF Temperature = 999
05
THEN
06
IF Temperature > 38.0
07
THEN
08
OUTPUT "Temperature too high"
09
ENDIF
10
IF Temperature < 35.0
11
THEN
12
OUTPUT "Temperature too low"
13
ENDIF
14
IF Temperature >= 35.0 OR Temperature <= 38.0
15
THEN
16
OUTPUT "Temperature normal"
17
ENDIF
18
ENDIF
19 WHILE Temperature = 999
(a) Identify the line numbers of four errors in the pseudocode and suggest a correction for each
error.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
Error 4 line number …
Correction …
…
[4]
ĬÑĊ®Ġ´íÈõÏĪÅĊÞüµĀ×
,
,
(b) Identify the temperature range used.
…
…
… [2]
(c) Complete the trace table for the corrected algorithm using this data:
34.22, 36.1, 37.4, 38.0, 999, –1
Temperature
OUTPUT
[2]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞúµĀ×

71
0478/21/O/N/24 · Question 11Oct/Nov 2024Paper 2115 marks
Loading question…
Question text

11
A running club has 200 members who compete in a 1-kilometre running competition every month.
Members’ names are stored in the one-dimensional (1D) array MemberName[]
Each member’s time, in seconds, for the 1-kilometre run will be stored in another one-dimensional
(1D) array MemberTime[]
The position of each member’s data in the two arrays is the same. For example, the member
stored at index 10 in MemberName[] and at index 10 in MemberTime[] is the same.
The running club awards a small prize to the members who have the top three times.
The club also awards certificates to all members with a time under 240 seconds.
Write a program that meets the following requirements:
•
allows members’ times to be input twice and verifies that the inputs match
•
sorts the arrays MemberTime[] and MemberName[] in ascending order of time
•
outputs the member names and times of the members with the top three times and identifies
them as First, Second and Third
•
stores the names of all the members who will receive a certificate in the array
MemberCertificate[]
•
outputs a message stating the number of certificates to be printed.
You must use pseudocode or program code and add comments to explain how your code works.
You do not need to initialise the data in the array MemberName[]
You do not need to declare any arrays or variables; you may assume that this has already been
done.
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
ĬÑĊ®Ġ´íÈõÏĪÅĊÝü·Ā×
,
,
…
…
…

72
0478/22/O/N/24 · Question 2Oct/Nov 2024Paper 221 marks
Loading question…
Question text

2
Tick (✓) one box to complete this sentence.
A pseudocode example of a selection statement is
A
CALL Sorting(Value1, Value2)
B
DECLARE Count : INTEGER
C
IF X = 7 THEN Y
21 ENDIF
D
WHILE X <> -1 DO
[1]

73
0478/22/O/N/24 · Question 4Oct/Nov 2024Paper 228 marks
Loading question…
Question text

4
This pseudocode algorithm is intended to sort a pre-populated one-dimensional (1D) array named
ItemList into alphabetical order using a bubble sort.
01
DECLARE ItemList : ARRAY[1:100] OF STRING
02
DECLARE Counter : STRING
03
DECLARE Limit : INTEGER
04
DECLARE Pass : INTEGER
05
DECLARE Swapped : BOOLEAN
06
DECLARE Temp : STRING
100
07
Limit
1
08
Pass
TRUE
09
Temp
10
WHILE Swapped = TRUE OR Pass <= Limit - 1 DO
FALSE
11
Swapped
1 TO Limit – Pass
12
FOR Counter
13
IF ItemList[Counter] > ItemList[Counter + 1]
14
THEN
ItemList[Counter]
15
Temp
ItemList[Counter + 1]
16
ItemList[Counter]
Temp
17
ItemList[Counter]
TRUE
18
Swapped
19
ENDCASE
Pass + 1
20
Pass
21
NEXT Counter
22
ENDWHILE
(a) Identify the line numbers of five errors in the pseudocode and suggest a correction for each
error.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
Error 4 line number …
Correction …
…
ĬÍĊ®Ġ´íÈõÏĪÅĊßù·Ā×
,
,
Error 5 line number …
Correction …
…
[5]
(b) A bubble sort algorithm can be written to include features that make it more efficient.
Explain why the corrected bubble sort algorithm is efficient.
…
…
…
…
…
… [3]

Advertisement
74
0478/22/O/N/24 · Question 7Oct/Nov 2024Paper 228 marks
Loading question…
Question text

7
This pseudocode represents an algorithm.
An input of –1 will terminate the algorithm.
DECLARE Count : INTEGER
DECLARE Answer : INTEGER
DECLARE Value : INTEGER
REPEAT
INPUT Value
IF Value <> -1
THEN
Value
Answer
Value - 1 TO 1 STEP -1
FOR Count
Answer * Count
Answer
NEXT Count
OUTPUT Answer
ENDIF
UNTIL Value = -1
(a) Complete the trace table for the input data:
5, 6, –1, 20, 9, 4
Value
Count
Answer
OUTPUT
[5]
ĬÑĊ®Ġ´íÈõÏĪÅĊÞû¶þ×
,
,
(b) State the purpose of this algorithm.
…
… [1]
(c) Describe the problem that would be caused in this algorithm if a Value of 1, 0 or less than –1
was input.
…
…
…
… [2]

75
0478/22/O/N/24 · Question 10Oct/Nov 2024Paper 226 marks
Loading question…
Question text

10 The function LENGTH(X) calculates the length of a string X
Write the pseudocode statements to:
•
allow a line of text to be input to an appropriate variable
•
store this line of text in a text file called Main.txt
•
calculate the length of the line of text and output the text in lower case along with its length
•
store the lower-case line of text in a text file called Lowercase.txt
Make sure that any variables used are declared and that both text files are closed after they have
been used.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
ĬÓĊ®Ġ´íÈõÏĪÅĊàù¶Ā×

Advertisement