For Loop Accumulator Variable
Consider the following code segment. What value is printed when the code is executed?
public class Savings {
public static void main(String[] args) {
int total = 0;
for(int day = 1; day <= 7; day++) {
total += day * 2;
}
System.out.println(total);
}
}
A
28
B
49
C
54
D
56
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | hadleysmith5 | 2 | 2 | 0m 00s | 200 |
| #2 | hitrishabhatia | 1 | 1 | 0m 00s | 100 |
| #3 | sgarv2513 | 1 | 1 | 0m 00s | 100 |
| #4 | mertdeg | 1 | 4 | 0m 00s | 70 |
| #5 | y.seong2027 | 1 | 1 | 0m 44s | 56 |
| #6 | midnightasdark | 1 | 2 | 1m 43s | -13 |
| #7 | yuvansankarnyc | 1 | 1 | 2m 01s | -21 |
| #8 | gtsak31 | 1 | 1 | 2m 50s | -70 |
| #9 | suhanakochhar006 | 1 | 1 | 9m 19s | -459 |
| #10 | Pelisx | 1 | 1 | 25m 55s | -1,455 |
Items per page:
10
1 – 10 of 10
