for i in 1...3 {
for j in 1...3 {
if j == 2 {
continue
}
print("i = (i), j = (j)")
}
}
// outer loop
for i in 1...5 {
// codes
// inner loop
for j in 1...2 {
//codes
}
}
// Swift program to display 7 days of 2 weeks
// outer loop
for week in 1...2 {
print("Week: (week)")
// inner loop
for day in 1...7 {
print(" Day: (day)")
}
// line break after iteration of outer loop
print("")
}
// outer loop
for week in 1...3 {
print("Week: (week)")
// inner loop
for day in 1...7 {
if(week == 2) {
// use of break statement
break
}
print(" Day: (day)")
}
print("")
}
// outer for loop
for i in 1...3 {
// inner for loop
for j in 1...3 {
if i == 2 {
break
}
print("i = (i), j = (j)")
}
}