A server room contains eight server racks numbered from 0 to 7.
The power consumption (in kilowatts) of each rack is stored in an array named power_draw.
The index of the power_draw array represents the rack number.
power_draw| Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| Data | 4.2 | 3.8 | 5.5 | 6.1 | 0.0 | 4.9 | 3.2 | 5.0 |
The following program is intended to calculate and output the total power consumption across all server racks.
for index = 1 to 7
total_power = 0
total_power = total_power + power_draw[index]
next index
print(total_power)
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.