7Testing DebuggingMedium4 marks
An algorithm has been written in pseudocode for a user to repeatedly input positive whole numbers and store them in an array called Values[] until is input or until the array is full. The algorithm outputs the average of the numbers to 2 decimal places.
DECLARE Counter : INTEGERDECLARE Total : INTEGERDECLARE Average : INTEGERDECLARE Values : ARRAY[1:100] OF INTEGERCounter ← 1Total ← 0OUTPUT "Please enter a positive whole number or -1 "INPUT NumberWHILE Number = -1 AND Counter <= 100 DOValues[Counter] ← NumberTotal ← Total + 1Counter ← Counter + 1INPUT NumberENDWHILECounter ← Counter - 1Average ← Counter / TotalOUTPUT "The average is ", ROUND(Average, 2)
Identify the line numbers of four errors in the pseudocode and suggest a correction for each error.
Answer
0 words