While Loop Execution Trace
What is printed when the following code segment is executed?
int sum = 0;
int num = 1;
while (sum < 20) {
sum += num;
num += 2;
}
System.out.println(sum);
A
24
B
25
C
21
D
20
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | hitrishabhatia | 1 | 1 | - | 100 |
| #2 | raufyildirim95 | 1 | 1 | 2m 30s | -50 |
| #3 | midnightasdark | 1 | 2 | 3h 00m | -10,724 |
Items per page:
10
1 – 3 of 3
