which each successive number is the sum of the two preceding numbers. A programmer has written the following algorithm which contains an error 1. first 2. second 3. first print second 5. for counter =1 to 5 6. sum = first + second 7. = second 8. second = sum 9. print first 10. end loop (a) The programmer decides to create a trace table to locate the error. The trace table shows the value of variable first, second and sum at the end of each pass through the loop. Copy and complete the trace table below. The expected output is 2, 3, 5, 8, 13, 21, 34. The actual output does (b) not match. (i) State the actual output of the algorithm for the first five values. 1 (ii) Explain how the algorithm be corrected. 1 (c) A programmer can use to the execution of a breakpoints
which each successive number is the sum of the two preceding numbers. A programmer has written the following algorithm which contains an error 1. first 2. second 3. first print second 5. for counter =1 to 5 6. sum = first + second 7. = second 8. second = sum 9. print first 10. end loop (a) The programmer decides to create a trace table to locate the error. The trace table shows the value of variable first, second and sum at the end of each pass through the loop. Copy and complete the trace table below. (b) The expected output is 2, 3, 5, 8, 13, 21, 34. The actual output does not match. (i) State the actual output of the algorithm for the first five values. (ii) Explain how the algorithm be corrected. 1 1 (c) A programmer can use breakpoints to the execution of a
SDD%20questions.docx