What does this print?
<code>int n = 0; for (int i = 1; i <= 4; i++) { if (i % 2 == 0) n += i; } System.out.println(n); </code></pre>
- A
8
- Bcheck_circle
6
- C
10
- D
12
Explanation
Add even i: 2 + 4 = 6.
AP Computer Science A· difficulty 4/5
What does this print?
<code>int n = 0; for (int i = 1; i <= 4; i++) { if (i % 2 == 0) n += i; } System.out.println(n); </code></pre>
8
6
10
12
Explanation
Add even i: 2 + 4 = 6.
Want 10 more like this — adaptive to your weak spots?