Programming – IGCSE Computer Science (0478)

270 questions · page 13 of 18 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
181
0478/22/O/N/20 · Question 4Oct/Nov 2020Paper 226 marks
Loading question…
Question text

4
This pseudocode algorithm allows 5000 numbers to be entered and stored in an array called
Number.
1 TO 5000
FOR Count
INPUT Number[Count]
NEXT Count
Extend and re-write the algorithm using pseudocode to also count and output how many of the
numbers stored in the array are greater than 500, using the variable Higher. Only output Higher
once with an appropriate message.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]

182
0478/22/O/N/20 · Question 5Oct/Nov 2020Paper 2227 marks
Loading question…
Question text

5
This pseudocode represents an algorithm.
REPEAT
0
Flag
0 to 3
FOR Count
IF Num[Count] < Num[Count + 1]
THEN
Num[Count]
Store
Num[Count + 1]
Num[Count]
Store
Num[Count + 1]
1
Flag
ENDIF
NEXT Count
UNTIL Flag = 0
(a) The contents of the array at the start of the algorithm are:
Num[0]
Num[1]
Num[2]
Num[3]
Num[4]
45
56
30
12
15
Complete the trace table for the algorithm using the data given in the array.
Flag
Count
Num[0]
Num[1]
Num[2]
Num[3]
Num[4]
Store
45
56
30
12
15
[5]
(b) Describe the purpose of the algorithm.
…
…
…
… [2]

183
0478/23/O/N/20 · Question 1Oct/Nov 2020Paper 2320 marks
Loading question…
Question text

1
All variables, constants and other identifiers must have meaningful names.
(a) Identify one constant and identify one variable that you could have used for Task 1. Give the
value that would be assigned to the constant. Give the data type for the variable. State what
each one could be used for.
Constant …
Value …
Use …
…
Variable …
Data type …
Use …
…
[6]
(b) (i)
Write an algorithm to allow a customer to choose the filling and salad items for their
baguette (part of Task 1), using either pseudocode, programming statements or a
flowchart. Your algorithm must only include this part of Task 1.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement
184
0478/23/O/N/20 · Question 2Oct/Nov 2020Paper 2312 marks
Loading question…
Question text

2
An algorithm has been written in pseudocode to check the temperature readings taken from a
freezer are within the range –18 degrees to –25 degrees inclusive.
The algorithm counts the number of times that the temperature reading is below –25 degrees and
the number of times that the temperature reading is above –18 degrees.
An engineer is called if there are more than 10 temperature readings below –25 degrees.
An alarm sounds if there are more than 5 temperature readings above –18 degrees.
0
01
TooHot
1000
02
TooCold
03
REPEAT
04
OUTPUT "Please enter temperature"
05
INPUT Temperature
06
IF Temperature < -25
07
THEN
TooCold – 1
08
TooCold
09
ENDIF
10
IF Temperature > -18
11
THEN
TooHot + 1
12
TooHot
13
ENDIF
14
UNTIL TooHot > 5 OR TooCold > 10
15
IF TooHot < 5
16
THEN
17
INPUT "Alarm!!"
18
ENDIF
19
IF TooCold > 10
20
THEN
21
OUTPUT "Call the Engineer"
22
ENDIF
(a) Give the line number(s) from the algorithm of:
an assignment statement …
a loop …
a counting statement …
a selection statement …
[4]
(b) Give line numbers where the four errors are to be found in the pseudocode. 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]
(c) Explain how you could extend the algorithm to count the number of times the temperature
readings are within the range –18 degrees to –25 degrees inclusive.
…
…
…
…

185
0478/23/O/N/20 · Question 3Oct/Nov 2020Paper 234 marks
Loading question…
Question text

3
Four programming concepts and five descriptions are shown.
Draw a line to connect each Programming concept to its correct Description. Not all Descriptions
will be connected to a Programming concept.
Programming concept
Description
A subroutine that does not have to
Validation
return a value
An automatic check to ensure that data
input is reasonable and sensible
Verification
A subroutine that always returns
a value
Procedure
An overview of a program or subroutine
A check to ensure that data input
Function
matches the original
[4]
Question 4 starts on Page 12.

186
0478/23/O/N/20 · Question 4Oct/Nov 2020Paper 236 marks
Loading question…
Question text

4
This flowchart represents an algorithm that allows the input of two numbers and performs a
calculation.
The predefined function MOD finds the remainder from integer division for example X
8 MOD 5
gives X a value of 3.
START
INPUT
Y,Z
Yes
IS
END
Y = 0 ?
No
Yes
IS
A
Y MOD Z
Y > Z ?
No
A
Z MOD Y
IS
Yes
OUTPUT
A = 0 ?
"Valid"
No
OUTPUT
"Invalid"
(a) Complete a trace table for this set of input data:
11, 4, 6, 2, 3, 9, 3, 2, 2, 6, 0, 0, 1, 1
Y
Z
A
OUTPUT
[4]
(b) Explain the purpose of this algorithm.
…
…
…
… [2]

187
0478/21/M/J/20 · Question 1May/June 2020Paper 2120 marks
Loading question…
Question text

1
All variables, constants and other identifiers must have meaningful names.
(a) (i)
Identify two arrays you could have used for Task 1 and, in each case, state its purpose.
Array 1 …
Purpose …
…
…
Array 2 …
Purpose …
…
…
[4]
(ii)
Identify two variables you could have used for Task 1 and, in each case, state its
purpose.
Variable 1 …
Purpose …
…
…
Variable 2 …
Purpose …
…
…
[4]
(b) Explain why the item code data could not be stored as a real data type and identify the most
suitable data type for the item code data.
…
…
…
…
…
… [2]
(c) Write an algorithm to show how you input your choice of mobile device and SIM card (part of
Task 1), using either pseudocode, programming statements or a flowchart. It is not necessary
to show initialisation or setting up of arrays containing product details.
…
…

188
0478/21/M/J/20 · Question 4May/June 2020Paper 218 marks
Loading question…
Question text

4
The pseudocode algorithm shown should allow numbers to be entered and should allow
50 numbers to be stored in an array.
←
0
Count
REPEAT
INPUT Values[Count]
←
Count + 1
Count
UNTIL Count = 0
(a) Explain why the algorithm will never end.
…
…
…
…
… [2]
(b) Re-write the original pseudocode so that it terminates correctly and also prevents numbers
below 100 from being stored in the array Values[ ]
…
…
…
…
…
…
…
…
…
… [4]
(c) Describe how you could change your pseudocode in part (b) so that it prevents numbers
below 100 and above 200 from being stored in the array Values[ ]
…
…
…
… [2]

Advertisement
189
0478/21/M/J/20 · Question 5May/June 2020Paper 216 marks
Loading question…
Question text

5
The flowchart represents an algorithm.
The predefined function DIV gives the value of the result of integer division,
←
9 DIV 4 gives y a value of 2
for example, y
An input value of –1 ends the algorithm.
START
INPUT
Value
IS
Yes
Value =
-1 ?
No
Calc1
Value DIV 2
Calc2
Value DIV 3
IS
No
Calc1 =
Value / 2 ?
Yes
IS
No
Calc2 =
Value / 3 ?
Yes
OUTPUT
Value
END
(a) Complete the trace table for the input data:
50, 33, 18, 15, 30, –1, 45, 12, 90, 6
Value
Calc1
Calc2
OUTPUT
[4]
(b) Describe the purpose of the algorithm.
…
…
… [2]

190
0478/22/M/J/20 · Question 1May/June 2020Paper 2220 marks
Loading question…
Question text

1
All variables, constants and other identifiers must have meaningful names.
(a) Identify two variables that you could have used for Task 1. Give the data type and state the
use of each variable.
Variable 1 …
Data type …
Use …
…
Variable 2 …
Data type …
Use …
…
[4]
(b) Data input by a customer for Task 1 includes the day and the hour of arrival.
Identify one suitable validation check for each input and justify your choice. Your validation
checks must be different.
Day of arrival – validation check …
…
Justification …
…
…
…
Hour of arrival – validation check …
…
Justification …
…
…
…
[4]
(c) Explain how your program for Task 1 ensured that the frequent parking number entered by
the customer had a valid check digit.
…
…
…
…

191
0478/22/M/J/20 · Question 2May/June 2020Paper 225 marks
Loading question…
Question text

2
Most programming languages include basic data types. Ahmad is describing the basic data types
he has used.
State the data type that Ahmad is describing in each sentence.
Choose the data type from this list of programming terms.
Array
Boolean
Char
Constant
Function
Integer
Iteration
Procedure
Real
String
Variable
A number with a fractional part that can be positive or negative and used in calculations
Data type …
A whole number that can be positive, negative or zero and used in calculations
Data type …
A single number, symbol or letter
Data type …
A sequence of characters
Data type …
A data type with two values, True or False
Data type …
[5]

192
0478/23/M/J/20 · Question 1May/June 2020Paper 2320 marks
Loading question…
Question text

1
All variables, constants and other identifiers must have meaningful names.
(a) (i)
Identify one array you could have used for Task 1 and state its purpose.
Array …
Purpose …
…
…
[2]
(ii)
Identify one variable you could have used for Task 2 and state its purpose.
Variable …
Purpose …
…
…
[2]
(iii)
Identify one constant you could have used for Task 3 and state its purpose.
Constant …
Purpose …
…
…
[2]
(b) Explain why a student would be advised not to store the Healthy? data as a real data type
and identify the most suitable data type for the Healthy? data.
…
…
…
…
…
… [2]
(c) Write an algorithm for Task 1 using either pseudocode, programming statements or a
flowchart. It is not necessary to show initialisation or setting up of arrays.
…
…
…
…
…
…

193
0478/23/M/J/20 · Question 2May/June 2020Paper 234 marks
Loading question…
Question text

2
Draw a line to connect each Description to the most appropriate Pseudocode example.
Description
Pseudocode example
A loop that will iterate
CASE … OF … OTHERWISE … ENDCASE
at least once
A loop that will not be
Number + 1
Number
executed on the first test
if the condition is false
WHILE … DO … ENDWHILE
A conditional statement
Sum
Sum + NewValue
Totalling
REPEAT … UNTIL
Counting
[4]

Advertisement
194
0478/23/M/J/20 · Question 5May/June 2020Paper 235 marks
Loading question…
Question text

5
This algorithm finds prime numbers.
The pre-defined function DIV gives the value of the result of integer division,
9 DIV 4 gives y a value of 2
for example, y
False
Flag
INPUT Number
WHILE Number <> 0
2
Divisor
WHILE Divisor <= Number / 2
Number DIV Divisor
Value
IF Number / Divisor = Value
THEN
True
Flag
ENDIF
Divisor + 1
Divisor
ENDWHILE
IF Flag = False
THEN
OUTPUT Number, " is prime"
ENDIF
INPUT Number
False
Flag
ENDWHILE
Complete the trace table for the algorithm using the input data:
5, 6, 8, 0, 11, 13
Flag
Number Divisor Value
OUTPUT
[5]

195
0478/22/F/M/20 · Question 1Feb/March 2020Paper 2220 marks
Loading question…
Question text

1
All variables, constants and other identifiers must have meaningful names.
(a) State the name of one constant that you could have used for Task 1. Give the value that
would be assigned to the constant. State the use of this constant.
Constant name …
Value …
Use …
…
[3]
(b) State the name of the variable that you used to store the amount offered for the trade-in of
an old car in Task 1. Give the most appropriate data type for this variable. Explain how your
program ensured that any data entered for the trade-in offer was valid.
Variable name …
Data type …
Validation …
…
…
…
[4]
(c) Snazzy Autos has decided to add another model to the cars available in Task 1. The new
model is a convertible, price Rs 6.75 lakh. Explain the changes required to your program for
Task 1.
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement