for loop swift 4 code example
Example 1: how to loop swift
for n in 1...5 {
print(n)
}
// Output: 1 2 3 4 5
Example 2: swift do while
var x = 0;
while x < 10 {
print "\(x)" //prints x until x < 10 evaluates to false
x = x + 1
}
for n in 1...5 {
print(n)
}
// Output: 1 2 3 4 5
var x = 0;
while x < 10 {
print "\(x)" //prints x until x < 10 evaluates to false
x = x + 1
}