Structured question 110 marks
A number sequence
The program below builds a sequence of numbers. The for loop includes its upper bound.
a = 1b = 1for n = 1 to 4c = a + ba = bb = cnext nprint(b)
(a) Complete4 marks
the trace table: one row at the end of each pass, then one row for print. Leave n blank in the print row.
| n | a | b | c | output |
|---|---|---|---|---|
| 1 | 1 | 2 | 2 | |
(b) State1 mark
the value printed if the loop runs for n = 1 to 6.
(c) Explain2 marks
why the order of lines 5 and 6 matters.
0 words
(d) Write3 marks
a loop that prints every even number from 2 to 20.