The pseudocode algorithm shown should allow numbers to be entered and should allow 50 numbers to be stored in an array. ``` Count ← 0 REPEAT INPUT Values [Count] Count← Count + 1 UNTIL Count = 0 ```
- (a)Explain why the algorithm will never end.[2]
- (b)Re-write the original pseudocode so that it terminates correctly and also prevents numbers below 100 from being stored in the array Values[ ][4]
- (c)Describe how you could change your pseudocode in part (b) so that it prevents numbers below 100 and above 200 from being stored in the array Values[ ][2]
Mark scheme
Marking points from the official mark scheme (May/June 2020). The mark or mark type is shown in brackets.
- [2] Any two correct statements (max two) e.g. The value of the variable Count begins as 0, and is incremented by 1 before it is tested by the loop condition, Count will never be 0 at the end of the loop
- [4] Count ← 0 REPEAT INPUT Number IF Number >= 100 THEN Values[Count] ← Number ENDIF Count ← Count + 1 UNTIL Count = 50
- One mark - separate INPUT statement
- One mark - IF statement attempted
- One mark - IF statement completely correct
- One mark - termination of loop updated
- [2] Any two correct statements (max two) e.g. Alter the IFstatement/add a second IF statement/comparison that's already there ..., so that additional criteria set an upper limit of <=200
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 →