Complete the code to print numbers from 1 to 5 using a for loop.
#include <iostream> int main() { for (int i = 1; i [1] 5; i++) { std::cout << i << std::endl; } return 0; }
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 inside the loop.
#include <iostream> int main() { for (int i = 1; i <= 5; i++) { if (i [1] 3) { continue; } std::cout << i << std::endl; } return 0; }
The continue statement should run only when i equals 3 to skip printing 3.
Fix the error in the while loop condition to stop the loop after printing numbers 1 to 5.
#include <iostream> int main() { int count = 1; while (count [1] 5) { std::cout << count << std::endl; count++; } return 0; }
The loop should continue while count is less than or equal to 5 to print numbers 1 through 5.
Fill both blanks to create a loop that prints even numbers from 2 to 10.
#include <iostream> int main() { for (int num = 2; num [1] 10; num [2]) { std::cout << num << std::endl; } return 0; }
The loop runs while num is less than or equal to 10, and increments by 2 each time to print even numbers.
Fill all three blanks to create a loop that prints numbers from 10 down to 1.
#include <iostream> int main() { for (int i = [1]; i [2] 1; i [3]) { std::cout << i << std::endl; } return 0; }
i instead of decreasing.The loop starts at 10, runs while i is greater than or equal to 1, and decrements by 1 each time.