Complete the code to print numbers from 1 to 5 using a for loop.
for (int i = 1; i [1] 5; i++) { System.out.println(i); }
The for loop should run while i is less than or equal to 5 to print numbers 1 through 5.
Complete the code to sum numbers from 1 to 10 using a for loop.
int sum = 0; for (int num = 1; num [1] 10; num++) { sum += num; } System.out.println(sum);
The loop must include 10, so the condition should be 'num <= 10'.
Fix the error in the for loop that counts down from 5 to 1.
for (int i = 5; i [1] 1; i--) { System.out.println(i); }
When counting down, the loop should continue while i is greater than or equal to 1 to print numbers from 5 down to 1.
Fill both blanks to create a for loop that prints even numbers from 2 to 10.
for (int i = [1]; i [2] 10; i += 2) { System.out.println(i); }
The loop starts at 2 and runs while i is less than or equal to 10 to print even numbers up to 10.
Fill all three blanks to create a for loop that prints the squares of numbers from 1 to 5.
for (int [1] = 1; [2] [3] 5; [1]++) { System.out.println([1] * [1]); }
The variable i is used for counting from 1 to 5 inclusive, printing squares.