Nested For Loop Execution Count
Consider the following code segment. What is the total number of times the statement count++ is executed?
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
8
B
12
C
4
D
10
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 | zgj07310417 | 0 | 1 | 2m 17s | -147 |
| #5 | chunxiangxu.cxu | 1 | 1 | 6m 48s | -308 |
| #6 | lsj08030922 | 1 | 1 | 2h 37m | -9,374 |
Items per page:
10
1 – 6 of 6
