Professional Documents
Culture Documents
Identtying Errors in Algorithms
Identtying Errors in Algorithms
Identtying Errors in Algorithms
Read this section of program code that should input 50 numbers and then output the
average.
1 Total = 0
2 For Counter = 1 TO 50
3 INPUT Num
4 Total = Total + 1
5 Counter = Counter + 1
6 Average = Total/Counter
7 NEXT Counter
8 PRINT Average
There are four errors in this code. Locate these errors and suggest code corrections to
remove each error.[4]
1 ................................................................................................................................................
........
2 ................................................................................................................................................
.......
3 ................................................................................................................................................
.........
4 ................................................................................................................................................
.......
Question 3 : 0478_s20_qp23 NO 3
This section of pseudocode is to be used as a validation check that will continue until a number between 0 and 499
inclusive is entered.
INPUT Number
WHILE NUMBERS <> 999 DO
IF Number > 100 THEN PRINT Number ENDIF
ENDWHILE
PRINT Number
(a) Find the four errors in the pseudocode and suggest corrections.
Error 1 .......................................................................................................................................
Correction ................................................................................................................................
.
Error
2 .......................................................................................................................................
Correction ...............................................................................................................................
Error 3 .......................................................................................................................................
Correction ................................................................................................................................
.
Error 4 .......................................................................................................................................
Correction ................................................................................................................................
.
Question 5 : 0478_m19_qp22 No 2
(a) An algorithm has been written in pseudocode to input 50 numbers and total only the
positive numbers.
Find the four errors in the pseudocode and suggest a correction for each error.
[4]
Error 1 .......................................................................................................................................
Correction ................................................................................................................................
.
Error 2 .......................................................................................................................................
Correction ................................................................................................................................
.
Error 3 .......................................................................................................................................
Correction ................................................................................................................................
.
Error 4 .......................................................................................................................................
Correction ................................................................................................................................
.
Marking Scheme
Question 1
Question 2
Question 3
Question 4
Question 5