What does this print?
<code>int n = 25; int p = 0; while (p * p < n) p++; System.out.println(p); </code></pre>
- A
6
- Bcheck_circle
5
- C
25
- D
4
Explanation
p²<25: p=0,1,2,3,4 (16<25 true→p=5); 5²=25 not <25, stop. Prints 5.
AP Computer Science A· difficulty 4/5
What does this print?
<code>int n = 25; int p = 0; while (p * p < n) p++; System.out.println(p); </code></pre>
6
5
25
4
Explanation
p²<25: p=0,1,2,3,4 (16<25 true→p=5); 5²=25 not <25, stop. Prints 5.
Want 10 more like this — adaptive to your weak spots?