Best loop to sum even numbers from 0 to 20
- A
while (i < 20)
- B
for (int i = 1; i <= 20; i += 2)
- C
for (int i = 0; i <= 20; i++)
- Dcheck_circle
for (int i = 0; i <= 20; i += 2)
Explanation
Step by 2 starting from 0.
AP Computer Science A· difficulty 3/5
Best loop to sum even numbers from 0 to 20
while (i < 20)
for (int i = 1; i <= 20; i += 2)
for (int i = 0; i <= 20; i++)
for (int i = 0; i <= 20; i += 2)
Explanation
Step by 2 starting from 0.
Want 10 more like this — adaptive to your weak spots?