Exam-style question
Try this first
An algorithm is defined by the following pseudocode: ```pseudocode 1. PROCEDURE CalculateValue 2. DECLARE result AS INTEGER 3. DECLARE num1 AS INTEGER 4. DECLARE num2 AS INTEGER 5. 6. INPUT num1 7. INPUT num2 8. 9. IF num1 > num2 THEN 10. result = num1 - num2 11. ELSE 12. result = num1 * num2 13. END IF 14. 15. OUTPUT result 16. END PROCEDURE ``` Complete the trace table below for the given inputs `num1 = 7` and `num2 = 4`. | Line No. | num1 | num2 | result | Output | |----------|------|------|--------|--------| | 6 | | | | | | 7 | | | | | | 9 | | | | | | 10/12 | | | | | | 15 | | | | | [5 marks].
Answer and explanation
Concise answer
| Line No.
Why this is correct
1 mark for correct `num1` value at line 6. 1 mark for correct `num2` value at line 7. 1 mark for showing value from `num1 > num2` condition (implicitly or explicitly). 1 mark for correct `result` value (3) at line 10/12. 1 mark for correct `Output` value (3) at line 15.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
