For Loop Accumulator
What is printed when the following code segment is executed?
int sum = 0;
for (int k = 1; k <= 5; k++) {
sum += k;
}
System.out.println(sum);
A
10
B
25
C
15
D
5
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | lsj08030922 | 1 | 1 | - | 100 |
| #2 | hitrishabhatia | 1 | 2 | - | 90 |
| #3 | midnightasdark | 1 | 1 | 1m 56s | -16 |
Items per page:
10
1 – 3 of 3
