A communications satellite has eight solar panels numbered from 0 to 7.
The power output (in watts) generated by each panel is stored in an array named power.
The index of the power array represents the panel number.
power| Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| Data | 45 | 12 | 0 | 38 | 55 | 29 | 14 | 42 |
The following program is intended to calculate and output the total power generated across all eight panels.
for k = 1 to 7
total = 0
total = total + power[k]
next k
print(total)
When tested, the program is found to contain two logic errors.
Describe how the program can be refined to remove these logic errors.
41 exam-style questions on OCR GCSE Computer Science Designing, creating and refining algorithms. Each one has a worked solution and a mark scheme showing where the marks go.