Programming – IGCSE Computer Science (0478)

270 questions · page 2 of 18 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
16
0478/23/M/J/26 · Question 2May/June 2026Paper 231 marks
Loading question…
Question text

2
Tick (3) one box to identify a programming data type used to store any combination of letters
and numbers.
A
char
B
Boolean
C
string
D
real
[1]

17
0478/23/M/J/26 · Question 3May/June 2026Paper 2311 marks
Loading question…
Question text

3
(a) Identify the type of test data in each description.
(i)
Data that falls within the accepted parameters of a validation check and is accepted.
… [1]
(ii)
Data that is the highest or lowest value to be accepted.
… [1]
(b) Explain the purpose of a check digit and give an example of where it could be used.
purpose …
…
…
…
…
example …
[3]
© Cambridge University Press & Assessment 2026
,
,
(c) Write the pseudocode for an algorithm to perform a validation check and a verification check
on a new password to meet the following criteria:
1
Input a new password.
2
If the password is less than 10 characters in length, ask for it to be input again until it is
at least 10 characters in length.
3
If the password is at least 10 characters in length, ask for it to be input a second time.
4
If both inputs of the new password match, output a password accepted message.
5
If both inputs of the new password do not match, go back to step 1 and ask for the new
password to be input for the first time.
Use appropriate input prompts and output messages to make the requirements clear to
the user.
Do not declare any arrays or variables for this algorithm.
…
…
…
…
…
…
…
…
…
…
…
…

18
0478/23/M/J/26 · Question 4May/June 2026Paper 2310 marks
Loading question…
Question text

4
This pseudocode algorithm is intended to store the names of up to 250 runners who finish a race.
The names of the runners are stored in a one‑dimensional (1D) array Runners[] and their time
in seconds in a one‑dimensional (1D) array Times[]. After the time for each runner has been
entered into the array, the name of the runner and the time of the runner in minutes and seconds
are displayed for verification.
Each runner takes 60 minutes or less to finish the race. A time of 60 minutes would be entered as
3600 seconds.
01
DECLARE Runners : ARRAY[1:250] OF STRING
02
DECLARE Times : ARRAY[1:250] OF INTEGER
03
DECLARE Index : INTEGER
04
DECLARE RunName : STRING
05
DECLARE RunTime : STRING
06
DECLARE RunMins : INTEGER
07
DECLARE RunSecs : INTEGER
1 TO 250
08
FOR Index
09
OUTPUT "Enter a runner’s name and then time (in seconds) "
10
INPUT RunName
11
OUTPUT RunTime
DIV(RunTime, 60)
12
RunMins
DIV(RunTime, 60)
13
RunSecs
14
OUTPUT "Runner’s Name: ", RunName
15
OUTPUT "Time: ", RunMins, " Minutes ", RunSecs, " Seconds"
RunMins
16
Runners[Index]
RunTime
17
Times[Index]
18
NEXT Index
(a) Identify the line numbers of 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]
© Cambridge University Press & Assessment 2026
,
,
(b) The algorithm is intended to work for positive finish times that are 3600 seconds or less, but
any number of seconds can currently be input.
(i)
Write the pseudocode statements to show how you would change the algorithm so that
only times in the correct range could be input. The time taken to finish the race needs to
be input again until valid data is input.
Clearly state where in the original algorithm your new statements would be placed.
Do not rewrite the whole algorithm.
…
…
…
…
…
…
…

Advertisement
19
0478/23/M/J/26 · Question 6May/June 2026Paper 235 marks
Loading question…
Question text

6
The string "I learnt to program in computer science" will be stored in the
variable Fact
(a) Complete the pseudocode algorithm to:
•
calculate and output the length of the string stored in the variable Fact
•
output, in upper case, the string stored in the variable Fact
"I learnt to program in computer science"
Fact
…
…
…
… [3]
(b) Write the pseudocode statements to use a string function to output the word program taken
from the string stored in the variable Fact
Do not declare any variables.
…
…
…
… [2]
© Cambridge University Press & Assessment 2026

20
0478/23/M/J/26 · Question 9May/June 2026Paper 236 marks
Loading question…
Question text

9
Outline two techniques that can be used to create a maintainable program.
1 …
…
…
…
…
…
2 …
…
…
…
…
…
[6]
© Cambridge University Press & Assessment 2026

21
0478/23/M/J/26 · Question 10May/June 2026Paper 2315 marks
Loading question…
Question text

10 Five rivers show signs of pollution and are to be monitored daily for a period of 30 days.
The one‑dimensional (1D) array RiverNames[] stores the names of the rivers.
The two‑dimensional (2D) array RiverStats[] stores the daily measurement of biological
oxygen demand (BOD) for each river.
The two‑dimensional (2D) array DaysCount[] stores the number of days each river is classed
as moderately polluted and the number of days each river is classed as highly polluted.
The position of the data for any river is the same in all three arrays. For example, the data in
index 2 of RiverStats[] belongs to the river in index 2 of RiverNames[]
Write a program for the following requirements:
•
Input and store the names of the rivers in the array RiverNames[]
•
For each river, input and store in the array RiverStats[], the daily BOD in milligrams per
litre (mg / L) on each of the 30 days.
•
Once all the inputs for the 30 days have been completed, the following statistics are
calculated, and when appropriate, stored:
◦
The average daily reading for each river, rounded to two decimal places.
◦
The number of days in which the BOD reading was between 2 mg / L and 8 mg / L
inclusive (moderate pollution) for each river.
◦
The number of days in which the BOD reading was greater than 8 mg / L (high pollution)
for each river.
•
Output for each river, the average daily BOD readings, the number of days with moderate
pollution and the number of days with high pollution.
•
Find and output the name of the river that has the most days with high pollution.
The program does not need to identify more than one river with an equally high pollution reading.
You must use pseudocode or program code and add comments to explain how your code works.
Do not declare arrays, variables or constants for this algorithm; assume this has been done.
You will need to initialise the arrays and any variables used for counting or totalling before they
are used.
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
…
…
© Cambridge University Press & Assessment 2026
,
,
…
…
…
…
…

22
0478/22/F/M/26 · Question 1Feb/March 2026Paper 221 marks
Loading question…
Question text

1
Tick (3) one box to identify the reason for applying a verification check to input data.
A
To make sure that all the data is in the correct range.
B
To make sure that all the data is accurate.
C
To make sure that no errors have been introduced during input.
D
To make sure that all the data is of the correct length.
[1]

23
0478/22/F/M/26 · Question 4Feb/March 2026Paper 221 marks
Loading question…
Question text

4
Tick (3) one box to identify which of the following does not help to create a
maintainable program.
A
Use meaningful identifiers for variable names.
B
Remove blank lines to make the program code shorter.
C
Use procedures and functions.
D
Use the commenting feature provided by the programming languages.
[1]
© Cambridge University Press & Assessment 2026
,
,
© Cambridge University Press & Assessment 2026

Advertisement
24
0478/22/F/M/26 · Question 5Feb/March 2026Paper 2211 marks
Loading question…
Question text

5
This pseudocode algorithm is intended to sort 200 names in ascending order, using a bubble
sort. The last names and first names are stored in separate columns of a two‑dimensional
(2D) array. The last names are stored in column 1 of the array.
01
// The array Names[] has already been declared as
02
// ARRAY[1:200, 1:2] OF STRING and it is already populated
03
DECLARE Row : STRING
04
DECLARE Temp1 : STRING
05
DECLARE Temp2 : STRING
06
DECLARE Swap : BOOLEAN
FALSE
07
Swap
08
WHILE NOT Swap DO
FALSE
09
Swap
2 TO 199
10
FOR Row
11
IF Names[Row, 1] > Names[Row + 1, 1]
12
THEN
Names[Row, 1]
13
Temp1
Names[Row, 2]
14
Temp2
Names[Row + 1, 1]
15
Names[Row, 1]
Names[Row + 1, 2]
16
Names[Row, 1]
Temp1
17
Names[Row + 1, 1]
Temp2
18
Names[Row + 1, 2]
FALSE
19
Swap
20
ENDIF
21
NEXT Column
22
ENDWHILE
(a) Identify the line numbers of five 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 …
…
© Cambridge University Press & Assessment 2026
,
,
error 5 line number …
correction …
…
[5]
(b) Write the pseudocode for an algorithm, using nested iteration, to output the contents
of Names[]
…
…
…
…
…
…
…
… [4]
(c) Describe a po

25
0478/22/F/M/26 · Question 6Feb/March 2026Paper 2211 marks
Loading question…
Question text

6
This flowchart represents an algorithm.
START
INPUT
Sentence
SentLength
LENGTH(Sentence)
LetterNo
1
Start
1
IS
Yes
SUBSTRING(Sentence,
LetterNo, 1) = " "
?
Word
SUBSTRING(Sentence,
Start, LetterNo – Start)
No
OUTPUT Word, " ",
LENGTH(Word)
Start
LetterNo + 1
LetterNo
LetterNo + 1
Yes
Word
SUBSTRING(Sentence,
No
IS LetterNo =
Start, LetterNo – Start + 1)
SentLength ?
OUTPUT Word, " ",
LENGTH(Word)
STOP
© Cambridge University Press & Assessment 2026
,
,
(a) Complete the trace table for the algorithm, using the given sentence.
Note: the start position of the sentence is index 1.
Sentence
SentLength
LetterNo
Start
Word
OUTPUT
Computing is fun
16
[5]
(b) Explain the purpose of the algorithm shown by the flowchart.
…
…
…
…
…
… [3]
© Cambridge University Press & Assessment 2026
,
,
(c) As currently written, the algorithm may be difficult to understand if it was used as a program.
Identify three improvements that could be made to the algorithm to make it more
user friendly.
…
…
…
…
…
… [3]
© Cambridge University Press & Assessment 2026

26
0478/22/F/M/26 · Question 9Feb/March 2026Paper 2215 marks
Loading question…
Question text

9
A program is required to enable voting in class surveys, for example to find the most
popular smartphone.
The one‑dimensional (1D) array Options[] is used to store between 2 and 12 options on which
users can vote.
The one‑dimensional (1D) array Votes[] is used to store the votes of between 2 and 1000 users.
The one‑dimensional (1D) array VoteCount[] is used to store the number of votes for each of
the options. The array index represents the option number.
Write a program for the following requirements:
•
Initialise all the arrays before they are used.
•
Input and validate the number of options and the number of voters.
•
Input each of the required options and store them in the array Options[]
•
Display the list of options for each voter and allow each voter to input their preferred option.
Validate this input and store it in the array Votes[]
•
Once all the votes have been input, count the number of voters who chose each option and
find the most and least popular options.
•
Output the most and least popular options as well as the number of voters who selected
each of these options.
The program does not need to identify if two or more options are the equal most or least popular.
You must use pseudocode or program code, and add comments to explain how your code works.
Do not declare arrays, variables or constants for this algorithm; assume this has been done.
Initialisation must be carried out as appropriate.
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
…
…
…
…
…
…
© Cambridge University Press & Assessment 2026
,
,
…
…
…
…

27
0478/21/O/N/25 · Question 3Oct/Nov 2025Paper 211 marks
Loading question…
Question text

3
Tick (✓) one box to identify the operator that returns the quotient of a calculation with the fractional
part discarded.
A
/
B
DIV
C
^
D
MOD
[1]
ĬÕĊ®Ġ´íÈõÏĪÅĊÝú¸þ×

28
0478/21/O/N/25 · Question 6Oct/Nov 2025Paper 219 marks
Loading question…
Question text

6
A check digit is one method to validate a 5-digit number.
The check digit for a 5-digit number is calculated as follows:
•
Each digit is multiplied by its position (the first digit on the left is in position 1).
•
The result of each multiplication is totalled.
•
MOD(Total, 11) is used to calculate the check digit.
•
If the result of the MOD function is 10, the check digit is ‘X’.
For example:
The calculation of the check digit for the 5-digit number 30475 is as follows:
Multiply each digit by its position and total the results:
(3 * 1) + (0 * 2) + (4 * 3) + (7 * 4) + (5 * 5) = 68
Calculate the check digit with MOD(Total, 11)
MOD(68, 11) = 2
The check digit for 30475 is 2
This pseudocode algorithm should calculate and output the check digit of a 5-digit number:
01
DECLARE Total : INTEGER
02
DECLARE Digit : INTEGER
03
DECLARE CheckDigit : CHAR
0
04
Total
1 TO 10
05
FOR Count
06
OUTPUT "Please enter digit ", Count
07
INPUT Digit
Total + (Digit / Count)
08
Total
09
NEXT Count
MOD(Total, 11)
10
CheckDigit
11
IF CheckDigit = 10
12
THEN
13
OUTPUT "The check digit is X"
14
ELSE
15
OUTPUT "The check digit is ", Count
16
ENDIF
ĬÙĊ®Ġ´íÈõÏĪÅĊÞüµþ×
,
,
(a) Identify the line numbers of the 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) Explain how you could modify the pseudocode to validate that each input is a single digit.
Any code must be fully explained.
…
…
…
…
… [3]
(c) The 5-digit number needs to be entered as a single input.
Describe one verification method that could be applied to the input of the 5-digit number.
…
…

Advertisement
29
0478/21/O/N/25 · Question 9Oct/Nov 2025Paper 214 marks
Loading question…
Question text

9
A school stores all the students’ attendance data in a file called Attendance.txt
Write an algorithm in pseudocode to read a line of text from the file and store this line in the
variable StudentAttendance
…
…
…
…
…
… [4]

30
0478/21/O/N/25 · Question 10Oct/Nov 2025Paper 215 marks
Loading question…
Question text

10 The variables Seconds and Minutes are used in a program. Seconds holds the number of
seconds as a whole number and Minutes holds the number of minutes as a whole number.
(a) Write pseudocode statements to declare the variables Seconds and Minutes
…
…
… [1]
(b) The procedure Time(TotalSeconds) takes the number of seconds as a parameter. The
procedure converts the value held in the parameter into minutes and seconds and outputs
the result.
Write this procedure in pseudocode.
…
…
…
…
…
…
…
… [4]
ĬÛĊ®Ġ´íÈõÏĪÅĊßú·Ā×

Advertisement