Computer Science · May / June 2023 · Paper 22 · Question 7
0478
As printed in the paper
The question as text
An algorithm has been written in pseudocode to calculate a check digit for a four-digit number. The algorithm then outputs the five-digit number including the check digit. The algorithm stops when –1 is input as the fourth digit. 01 Flag FALSE 02 REPEAT 03 Total 0 04 FOR Counter 1 TO 4 05 OUTPUT "Enter a digit ", Counter 06 INPUT Number[Counter] 07 Total Total + Number * Counter 08 IF Number[Counter] = 0 09 THEN 10 Flag TRUE 11 ENDIF 12 NEXT Counter 13 IF NOT Flag 14 THEN 15 Number[5] MOD(Total, 10) 16 FOR Counter 0 TO 5 17 OUTPUT Number[Counter] 18 NEXT 19 ENDIF 20 UNTIL Flag
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
7(a)[3]
0704/12 or 16/1802/207(b)[3]
One mark for each error identified and correction
Line 07 Total ← Total + Number * Countershould be Total ← Total + Number[Counter] * Counter
Line 08 IF Number[Counter] = 0should be IF Number[Counter] = -1 // should be IF Number[Counter] < 0
Line 16 FOR Counter ← 0 TO 5should be FOR Counter ← 1 TO 5
7(c)[4]
One mark for place in algorithm (max one)
around lines 05 and 06line 07(immediately) after the input of the numberThree marks pseudocode
One mark for each point (max three)
Use of REPEAT … UNTIL // any working loop structurecheck for >0 // >=0check for <10 // >9check for whole numbercheck for -1check for length of digit <> 1Example
REPEAT
OUTPUT "Enter a digit "
INPUT Number[Counter]
UNTIL Number[Counter] = Round(Number[Counter],0) AND ((Number[Counter] = -1) OR
(Number[Counter] > 0 AND Number[Counter] < 10))
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

