0
0
Kotlinprogramming~10 mins

Break and continue behavior in Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to stop the loop when i equals 3.

Kotlin
for (i in 1..5) {
    if (i == 3) {
        [1]
    }
    println(i)
}
Drag options to blanks, or click blank then click option'
Abreak
Bcontinue
Creturn
Dexit
Attempts:
3 left
💡 Hint
Common Mistakes
Using continue instead of break, which skips the current iteration but does not stop the loop.
2fill in blank
medium

Complete the code to skip printing the number 3 but continue the loop.

Kotlin
for (i in 1..5) {
    if (i == 3) {
        [1]
    }
    println(i)
}
Drag options to blanks, or click blank then click option'
Areturn
Bbreak
Ccontinue
Dskip
Attempts:
3 left
💡 Hint
Common Mistakes
Using break instead of continue, which stops the loop entirely.
3fill in blank
hard

Fix the error in the code to correctly skip printing even numbers.

Kotlin
for (num in 1..6) {
    if (num % 2 == 0) [1]
    println(num)
}
Drag options to blanks, or click blank then click option'
Abreak
Bskip
Creturn
Dcontinue
Attempts:
3 left
💡 Hint
Common Mistakes
Using break causes the loop to stop early, not skip iterations.
4fill in blank
hard

Fill both blanks to create a loop that prints numbers 1 to 5 but stops before 4.

Kotlin
for (i in 1..5) {
    if (i [1] 4) {
        [2]
    }
    println(i)
}
Drag options to blanks, or click blank then click option'
A>=
B<
Cbreak
Dcontinue
Attempts:
3 left
💡 Hint
Common Mistakes
Using continue instead of break, which skips but does not stop the loop.
5fill in blank
hard

Fill all three blanks to print only odd numbers from 1 to 7.

Kotlin
for (n in 1..7) {
    if (n [1] 2 == 0) {
        [2]
    }
    println([3])
}
Drag options to blanks, or click blank then click option'
A%
Bcontinue
Cn
Dbreak
Attempts:
3 left
💡 Hint
Common Mistakes
Using break instead of continue, which stops the loop early.