Cie CS CH7 2
Cie CS CH7 2
Section B
2 (a) An algorithm has been written in pseudocode to input 100 numbers, select and print the
largest number and smallest number.
Count 1
INPUT Number
High Number
Low Count Low <- Number
REPEAT
INPUT Number
IF Number > High
THEN
High Number
ENDIF
IF Number > Low Number < Low
THEN
Low Number
ENDIF
Count Count + 1
UNTIL Count > 99 Count = 100
PRINT "Largest Number is ", Number High
PRINT "Smallest Number is ", Low
Find the four errors in the pseudocode and suggest a correction for each error.
Error 1 ........................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Error 2 ........................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Error 3 ........................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Error 4 ........................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
[4]
(b) Show how you would change the corrected algorithm to total the numbers and print the total.
Use a variable Total.
...................................................................................................................................................
Total <- Number
Total + Number
...................................................................................................................................................
...................................................................................................................................................
PRINT " Total is" , Total
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
3 This flowchart inputs the marks gained in an examination. An input of –1 ends the routine.
START
Total 0
Count 0
Distinction 0
INPUT Mark
Is Mark = –1 ? Yes
Total Total + Mark
Count Count + 1
No
No Is OUTPUT "Number of
Mark >= Distinctions ", Distinction
80 ? OUTPUT "Average Mark "
Total/Count
Yes
Complete the trace table for the mark input data: 50, 70, 65, 30, 95, 50, 55, 85, 65, 35, –1, 45
4 For each of the four groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.
Validation ..........................................................................................................................................
..........................................................................................................................................................
automated checking
checking that data is reasonable / of a certain type
..........................................................................................................................................................
checking that data meets certain criteria
..........................................................................................................................................................
Example ...........................................................................................................................................
range check, length check, type check, check digit
..........................................................................................................................................................
..........................................................................................................................................................
Verification ........................................................................................................................................
checking that data has not changed
..........................................................................................................................................................
during input to a computer
..........................................................................................................................................................
during transfer between computer devices
..........................................................................................................................................................
Example ...........................................................................................................................................
double entry, checking against original , visual check
..........................................................................................................................................................
..........................................................................................................................................................
[6]