Nested Loop Iteration Count
What is the total number of times the body of the inner loop will be executed in the following code segment?
for (int i = 0; i < 4; i++) {
for (int j = i; j < 4; j++) {
System.out.print(j);
}
}
A
12
B
8
C
9
D
10
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | bommasam000 | 4 | 4 | 1m 34s | 306 |
| #2 | theofanusmischa | 1 | 1 | 0m 00s | 100 |
| #3 | singhris000 | 1 | 1 | 2m 25s | -45 |
| #4 | suhanakochhar006 | 0 | 1 | 2m 03s | -133 |
| #5 | geethasailaja | 1 | 4 | 6m 19s | -309 |
| #6 | y.seong2027 | 1 | 3 | 6m 29s | -309 |
| #7 | midnightasdark | 2 | 4 | 8m 21s | -321 |
| #8 | sailajavadlamani33 | 0 | 1 | 7m 51s | -481 |
Items per page:
10
1 – 8 of 8
APFIVE