Complete the code to print numbers from 1 to 5 using a loop.
for(int i = 1; i [1] 5; i++) { printf("%d\n", i); }
The loop should run while i is less than or equal to 5 to print numbers 1 through 5.
Complete the code to skip printing the number 3 in the loop.
for(int i = 1; i <= 5; i++) { if(i [1] 3) { continue; } printf("%d\n", i); }
The continue statement skips the current iteration when i equals 3, so 3 is not printed.
Fix the error in the loop to avoid an infinite loop.
int i = 1; while(i [1] 5) { printf("%d\n", i); // Missing increment i++; }
The loop condition should be i < 5 and the loop must include an increment to avoid infinite looping. Here, the condition i < 5 is correct but the increment is missing, so the loop never ends.
Fill both blanks to create a loop that prints even numbers from 2 to 10.
for(int i = [1]; i [2] 10; i += 2) { printf("%d\n", i); }
The loop starts at 2 and runs while i <= 10, incrementing by 2 each time to print even numbers.
Fill all three blanks to create a loop that prints numbers from 10 down to 1.
for(int i = [1]; i [2] 1; i[3]) { printf("%d\n", i); }
The loop starts at 10, runs while i >= 1, and decrements i by 1 each time to print numbers from 10 down to 1.