Algorithm design and problem-solving – IGCSE Computer Science (0478)
200 questions · page 14 of 14
Question text
2
Read this section of program code that inputs positive numbers, discards any negative numbers
and then outputs the average. An input of zero ends the process.
1
Total = 0
2
Counter = 100
3
REPEAT
4
REPEAT
5
INPUT Num
6
UNTIL Num < 0
7
Total = Total + 1
8
Counter = Counter + Num
9
UNTIL Num = 0
10
Average = Total / (Counter - 1)
11
Print Average
There are four errors in this code.
Locate these errors and suggest a correction to remove each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
… [8]
Question text
The flowchart below inputs an integer. The predefined function DIV gives the value of the division,
3
for example Z ← 11 DIV 3 gives the value Z = 3. The predefined function MOD gives the value
of the remainder, for example Z ← 11 MOD 3 gives the value Z = 2.
67$57
,1387 ;
1R
Is X >
"
<HV
$
; ',9
287387 ;
%
; 02'
(1'
287387 %
;
$
Complete a trace table for each of the two input values 33 and 75.
Trace table for input value 33
X
A
B
OUTPUT
Trace table for input value 75
X
A
B
OUTPUT
[4]
Question text
4
The flowchart below inputs the height of children who want to ride on a rollercoaster. Children
under 1.2 metres are rejected. The ride starts when eight children have been accepted.
67$57
5LGHUV
5HMHFW
,1387
+HLJKW
,V
<HV
+HLJKW
5HMHFW 5HMHFW
"
1R
5LGHUV 5LGHUV
287387
<HV
1R
5LGHUV
5eady to go , 5eject
"
(1'
Complete the trace table for the input data:
1.4, 1.3, 1.1, 1.3, 1.0, 1.5, 1.2, 1.3, 1.4, 1.3, 0.9, 1.5, 1.6, 1.0
Riders
Reject
Height
OUTPUT
[4]
Question text
REPEAT ... UNTIL is one type of loop structure.
5
Identify and describe two other types of loop structure that you could use when writing
pseudocode.
Loop structure 1 …
Description …
…
Loop structure 2 …
Description …
… [4]
Question text
3
The flowchart below calculates the number of tins of paint required to paint walls. The flowchart
inputs the height and width of a wall in metres, the number of doors and the number of windows.
A value of –1 for the height stops the input.
START
Area
0
Tins
0
INPUT Height,
Width, Doors,
Windows
Is
Yes
Height
Tins
INT(Area/10 + 0.5)
= –1?
No
OUTPUT Tins
Area
Area + Height * Width
– Doors * 1.5 – Windows
END
Complete the trace table for the input data:
3, 5, 1, 0, 3, 7, 0, 0, 3, 5, 0, 3, 3, 7, 1, 1, –1, 0, 0, 0
Area
Tins
Height
Width
Doors
Windows
[4]