How does the Computer Code Execute?
Line 1) variable sum gets a value 0;
Line 2) variable i gets 0;
Line 3) mark the beginning of a while-loop;
Line 4) replace the value of variable i by its old value (0) plus 1. I.e., i = 1;
Line 5) replace the value of sum by its old value (0) + current value of i,
Line 6) is i < 3? yes, since I=1, so go back to line 4);
Line 4) value i increased by 1 to 2;
Line 5) value sum becomes 1 + 2 = 3;
Line 6) is i < 3? yes, since i = 2, go back to Line 4);
Line 4) i becomes 2 +1 = 3;
Line 5) sum becomes 3 + 3 = 6;
Line 6) is i < 3? no, since i = 3. Program stops.