Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 3 of 3.
The procedure changes the value it is given, and the loop uses that same variable.
Num is passed by reference (BYREF), but it should have been passed by value [1]
So when DisplaySqrt() changes ThisNum (line 52), the original variable Num is changed too [1]
The new value (the square root) is then used by the loop in lines 40 to 43, so Num no longer goes 1, 2, 3 ... [1]
The code does not break any rule of the language, so the compiler sees nothing wrong.
Write: there are no syntax errors, the rules of the language have not been broken (it is a logic / design error) [1]
Write any three of these uses of an IDE:
Set a breakpoint so the program stops at a chosen line [1]
Single-step through the program one line or statement at a time [1]
Check the value of Num or ThisNum in a watch / report window as it changes [1]
Write: turn the statement into a comment (put the comment symbol in front of it) [1]
Another accepted way is to change it into a string literal that is assigned to a variable or output.
▶ Starts at Q5 (31:40)
Starts at Q5 (31:40) · by Pseudocode Pro. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.