What is the final value of x?
<code>int x = 1; for (int i = 1; i <= 3; i++) x *= 2; </code></pre>
- A
4
- Bcheck_circle
8
- C
2
- D
16
Explanation
x doubles 3 times: 1 → 2 → 4 → 8.
AP Computer Science A· difficulty 4/5
What is the final value of x?
<code>int x = 1; for (int i = 1; i <= 3; i++) x *= 2; </code></pre>
4
8
2
16
Explanation
x doubles 3 times: 1 → 2 → 4 → 8.
Want 10 more like this — adaptive to your weak spots?