Complete the code to print numbers from 1 to 3 using a while loop.
i = 1 while [1] puts i i += 1 end
The while loop continues as long as the condition is true. Here, it runs while i is less than 4, printing 1, 2, and 3.
Complete the code to stop the loop when the variable reaches 5.
count = 0 while count [1] 5 puts count count += 1 end
The loop should run while count is less than 5, so it stops when count reaches 5.
Fix the error in the loop condition to print numbers from 1 to 4.
num = 1 while num [1] 5 puts num num += 1 end
The loop should run while num is less than 5 to print numbers 1 to 4.
Fill both blanks to create a while loop that prints even numbers from 2 to 8.
i = 2 while i [1] 8 puts i i [2] 2 end
i causing an infinite loop.The loop runs while i is less than or equal to 8, and i increases by 2 each time to print even numbers.
Fill all three blanks to create a while loop that prints numbers from 10 down to 6.
n = 10 while n [1] 5 puts [2] n [3] 1 end
n causes infinite loop.The loop runs while n is greater than 5, prints n, and decreases n by 1 each time.