Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-code - AQA - GCSE Computer Science - Question 2 - 2023 - Paper 1
Question 2
Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-code.
• Line numbers are included but are not part of the algorithm.
... show full transcript
Worked Solution & Example Answer:Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-code - AQA - GCSE Computer Science - Question 2 - 2023 - Paper 1
Step 1
Where is iteration first used in the algorithm in Figure 2?
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Iteration is first used at Line number 6, where the algorithm checks the condition of the while loop.
Step 2
In the algorithm in Figure 2, what will be output when the user input is 10?
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
When the user inputs 10, the output will be 2 since the algorithm will perform the integer division: 10 DIV 3 which evaluates to 3. The loop continues until 'a' becomes 0.
Step 3
In the algorithm in Figure 2, what is the largest possible value of the variable counter when the user input is 36?
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The largest possible value of the variable counter when the user input is 36 is 5, as after each iteration 'a' is reduced by integer division of 3.