Read this section of program code that inputs 10 positive numbers and then outputs the total. 1 Total = 0 2 Counter = 0 3 REPEAT 4 INPUT Num 5 Total = Total + Num 6 PRINT Total 7 Counter = Counter + 1 8 UNTIL Counter = 10 This code works, but it is inefficient.
- (i)Suggest three improvements that could be made.[3]
- (ii)Rewrite the program code with your improvements.[3]
Mark scheme
Marking points from the official mark scheme (May/June 2016). The mark or mark type is shown in brackets.
- [1] use FOR ... NEXT instead of REPEAT ... UNTIL
- [1] Move PRINT to after the end of the loop
- [1] Add error checking to check that the value input is positive
- [1] Total = 0
- [1] FOR Counter = 1 TO 10
- [1] REPEAT INPUT Num UNTIL Num >0
- [1] Total = Total + Num
- [1] NEXT Counter
- [1] PRINT Total
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →