Question 1
1 markThe algorithm below works out how many cars are needed for a trip, if each car can take 4 people.
OUTPUT 'Enter the number of people'
people ← USERINPUT
cars ← people DIV 4
IF people MOD 4 > 0 THEN
cars ← cars + 1
ENDIF
OUTPUT carsThe user enters 10. What is the final output?
Choose your answer.
- 2
- 3
- 2.5
- 4
Model answer
3
Explanation
10 DIV 4 is 2 full cars, and 10 MOD 4 is 2 people left over, which is more than 0, so one more car is added to make 3. 2.5 would come from ordinary division, which the algorithm does not output, and 2 ignores the people left over. The first output is only the prompt, so the final output is the number of cars.
Mark scheme
-
1 mark
3
If more than one option is given, 0 marks. Mark is for AO2 (apply).