Complete the code to print numbers from 1 to 5 using a while loop.
i <- 1 while (i [1] 5) { print(i) i <- i + 1 }
The condition i <= 5 ensures the loop runs while i is 1 through 5.
Complete the code to stop the loop when x reaches 10.
x <- 1 while (x [1] 10) { print(x) x <- x + 1 }
The condition x < 10 stops the loop before x becomes 10.
Fix the error in the loop condition to avoid an infinite loop.
count <- 5 while (count [1] 0) { print(count) count <- count - 1 }
The condition count > 0 ensures the loop stops when count reaches 0.
Fill both blanks to create a loop that prints even numbers from 2 to 10.
num <- 2 while (num [1] 10) { print(num) num <- num [2] 2 }
The loop runs while num is less than or equal to 10, and num increases by 2 each time.
Fill all three blanks to create a loop that prints squares of numbers from 1 to 5.
i <- 1 while (i [1] 5) { print(i [2] i) i <- i [3] 1 }
The loop runs while i is less than or equal to 5, prints i squared, and increases i by 1 each time.
