Recall & Review
beginner
What is the basic structure of a
for loop in Go?A
for loop in Go has three parts: initialization, condition, and post statement. It looks like: for i := 0; i < 5; i++ { /* code */ }Click to reveal answer
beginner
What happens when the condition in a Go
for loop becomes false?The loop stops executing and the program continues with the code after the loop.
Click to reveal answer
intermediate
How does the
continue statement affect loop execution in Go?The
continue statement skips the rest of the current loop iteration and moves to the next iteration immediately.Click to reveal answer
intermediate
What does the
break statement do inside a Go loop?The
break statement immediately exits the loop, skipping any remaining iterations.Click to reveal answer
intermediate
Can a Go
for loop run forever? How?Yes. If the loop condition is omitted or always true, the loop runs forever. Example:
for { /* infinite loop */ }Click to reveal answer
What part of the Go
for loop controls how many times it runs?✗ Incorrect
The condition expression is checked before each iteration. If false, the loop stops.
What does the
continue statement do inside a Go loop?✗ Incorrect
Continue skips the rest of the current iteration and moves to the next one.
Which statement immediately exits a Go loop?
✗ Incorrect
The break statement exits the loop immediately.
What happens if you omit the condition in a Go
for loop?✗ Incorrect
Omitting the condition makes the loop run forever (infinite loop).
In Go, which part of the
for loop runs after each iteration?✗ Incorrect
The post statement runs after each iteration, often used to update the loop variable.
Explain how the flow of execution works in a Go
for loop from start to finish.Think about the order of the three parts and when the loop body runs.
You got /5 concepts.
Describe the difference between
break and continue statements in Go loops.One stops the loop, the other skips to the next round.
You got /4 concepts.