121k views
4 votes
Which of the following represents the number of times the command moveForward() will be executed in the code segment below?

func move(distance:Int) {
for i in 1... distance {
moveForward()
}
}
move(distance:5)
a. 2
b.4
c.1
d.5

1 Answer

3 votes

Answer:

The last option is the correct choice.

Step-by-step explanation:

d. 5

The loop will execute 5 times.

Best Regards!

User Kevin Raoofi
by
4.6k points