Skip to the task
Layout
Back to classic view

You are looking at lesson 6. Your place is still lesson 7, task 1: Modules.

CHECKTask 20 of 28 · step 9: Drills: check yourself

Find the bug in the average

What is wrong with this loop?

for (int i = 1; i <= n; i++) {
    sum += t[i];
}
Stuck?

It skips t[0] and reads t[n], out of bounds. It must be for (int i = 0; i < n; i++).