Nested For Loop Execution Count
In the nested loops above, how many total iterations does the innermost statement execute?
public class LoopTest {
public static void main(String[] args) {
int count = 0;
for (int i = 1; i <= 4; i++) {
for (int j = 0; j < i; j++) {
count++;
}
}
System.out.println(count);
}
}
A
4
B
12
C
10
D
8
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | bommasam000 | 1 | 3 | 0m 49s | 31 |
| #3 | richa.tuli | 0 | 1 | 2m 01s | -131 |
| #4 | lsj08030922 | 1 | 1 | 2h 37m | -9,374 |
Items per page:
10
1 – 4 of 4
APFIVE