Skip to the task
Layout
Back to classic view

You are looking at lesson 4. Your place is still lesson 10, task 1: struct.

CHECKTask 21 of 23 · step 9: Drills: check yourself

How many times will it stop?

A breakpoint on sum += i;. How many times will the program stop, what will i be, and what is sum after the loop?

int sum = 0;
for (int i = 0; i <= 3; i++) {
    sum += i;
}
Stuck?

4 times: i = 0, 1, 2, 3 (<=, so 3 too). After the loop sum = 0 + 1 + 2 + 3 = 6.