← all problems

Trace: cumulative even sum

Consider the code below. Assume it compiles and runs correctly.

int total = 0;for (int i = 1; i <= 4; i++) {    total += i * 2;    System.out.println(total);}

1. What is printed by this code? Write each line of output on its own line.

2. What is the value of total immediately after the loop finishes?

Your score for your class is recorded when you click Submit all — checking individual questions doesn't save it. You can submit again to improve your score; your best one counts.