Complete the code to print numbers from 1 to 5 using a loop.
for(int i = 1; i <= [1]; i++) { System.out.println(i); }
The loop should run from 1 to 5, so the condition uses 5.
Complete the code to sum numbers from 1 to 4 using a loop.
int sum = 0; for(int i = 1; i <= [1]; i++) { sum += i; } System.out.println(sum);
The loop should add numbers from 1 to 4, so the condition uses 4.
Fix the error in the loop condition to print numbers from 0 to 3.
for(int i = 0; i [1] 3; i++) { System.out.println(i); }
The loop should include 3, so use <= to include it.
Fill both blanks to create a loop that prints even numbers from 2 to 6.
for(int i = [1]; i [2] 6; i += 2) { System.out.println(i); }
The loop starts at 2 and runs while i is less than or equal to 6 to include 6.
Fill all three blanks to create a loop that prints numbers from 5 down to 1.
for(int i = [1]; i [2] 1; i [3]) { System.out.println(i); }
The loop starts at 5, runs while i is greater than or equal to 1, and decreases i by 1 each time.
