Swift - Loops
Find the problem in this Swift code:
var i = 0
while i < 5 {
if i == 2 {
break
}
print(i)
}var i = 0
while i < 5 {
if i == 2 {
break
}
print(i)
}i is initialized but never incremented inside the loop.i stays 0, condition i < 5 is always true, causing infinite loop.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions