What's the sum after this loop?
<code>int[] arr = {3, 1, 4, 1, 5}; int sum = 0; for (int i = 0; i < arr.length; i++) sum += arr[i]; </code></pre>
- Acheck_circle
14
- B
13
- C
15
- D
20
Explanation
3 + 1 + 4 + 1 + 5 = 14.
AP Computer Science A· difficulty 3/5
What's the sum after this loop?
<code>int[] arr = {3, 1, 4, 1, 5}; int sum = 0; for (int i = 0; i < arr.length; i++) sum += arr[i]; </code></pre>
14
13
15
20
Explanation
3 + 1 + 4 + 1 + 5 = 14.
Want 10 more like this — adaptive to your weak spots?