- Fork the assignment repo
- Clone your Fork to your machine
- Complete the lab
- Push your changes to your Fork
- Submit a Pull Request back to the assignment repo
- Paste a link to of your Fork on Canvas and submit
What will the code below print?
var myNum = 8
for number in 4..<8{
if number == 7 {
break
} else {
myNum += number
}
}
print(myNum)
23
Which of the following loops will print out all the numbers between 1 and 100, inclusive? Select all that apply.
a)
for i in 1..<100 {
print(i)
}
B)
for j in 1...100 {
print(j)
}
C)
for k in 1..<1000 where k < 101 {
print(k)
}
D)
for l in 1...100 where _ < 101 {
print(l)
}
A, B, and C
How many times will the code below print "Nesting!" ?
for _ in 1...10{
for _ in 1...10{
print("Nesting!")
}
}
100 because it runs 10 times within each loop.
Which of the loops below will run forever? Select all that apply.
a)
var q = 0
while q%2 != 1 {
print("Hello Problem Two!")
q += 2
}
b)
var r = 0
while r < 10 {
print("Hi there!")
r += 11
}
c)
var s = 0
while 3 != 3 {
print("Howdy!")
s += 1
}
d)
var t = 0
while t == t{
print("Ahoy-hoy!")
t += 1
}
A and D will loop forever