Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Cambridge University Press 2011

Algorithm planning
and design
9
Revision questions: 9 Algorithm planning & design 1 Cambridge IGCSE Computer Studies
1 A school wants to calculate the number of hours spent in school by a sample of students from
time of arrival and departure data. Draw a structure diagram and a program fowchart for an
algorithm with the following features:
a For each student, enter the students name, the time of arrival and the time of departure.
b Calculate the length of time each student spends in school.
c Output the students name and the time spent in school.
2 Consider the following algorithm.
no
STOP
yes
Count = 10?
set Count,
LowCount,
HighCount to 0
START
yes
no
Temperature
< 18?
LowCount
LowCount + 1
output
LowCount,
HighCount
Count
Count + 1
yes
Temperature
>= 30?
HighCount
HighCount + 1
input
Temperature
no
Cambridge University Press 2011 Revision questions: 9 Algorithm planning & design 2 Cambridge IGCSE Computer Studies
a Complete the following trace table using the temperature values 14, 17, 23, 27, 29, 30,
32, 26, 18, 12.
Temperature LowCount HighCount Count
Output
0 0 0
14
b What is the purpose of the algorithm?
3 What is the purpose of the following algorithm?
no
START
STOP
Count 0
Total 0
Number
< 0 ?
Total Total + Number
yes
Count Count + 1
input
Number
input
Number
output
Count, Total,
Total / Count
Cambridge University Press 2011 Revision questions: 9 Algorithm planning & design 3 Cambridge IGCSE Computer Studies
4 Read this algorithm.
no
START
STOP
a > b ?
t b * 2
yes
input
a, b
t a * 2
output
a, b, t
a Write down the output if the two numbers input are 4 and 3. (a = 4 and b = 3.)
b Explain why an algorithm is written as a subroutine (procedure) and stored in a
programlibrary.

You might also like