Complete the code to stop the loop when i equals 3.
for (i in 1..5) { if (i == 3) { [1] } println(i) }
The break statement stops the loop immediately when the condition is met.
Complete the code to skip printing the number 3 but continue the loop.
for (i in 1..5) { if (i == 3) { [1] } println(i) }
The continue statement skips the current iteration and continues with the next one.
Fix the error in the code to correctly skip printing even numbers.
for (num in 1..6) { if (num % 2 == 0) [1] println(num) }
Using continue skips printing even numbers but continues the loop.
Fill both blanks to create a loop that prints numbers 1 to 5 but stops before 4.
for (i in 1..5) { if (i [1] 4) { [2] } println(i) }
The condition i >= 4 checks if i is 4 or more, and break stops the loop when i is 4 or more.
Fill all three blanks to print only odd numbers from 1 to 7.
for (n in 1..7) { if (n [1] 2 == 0) { [2] } println([3]) }
The modulo operator % checks for even numbers, continue skips them, and n prints the current number.
