Question 4
Back to Exercise
break is executed inside the inner loop of two nested loops. What happens?
- A Both loops end
- B Only the inner loop ends; the outer loop continues Correct
- C The program ends
- D Only the outer loop ends
Correct Answer: Option B
break leaves the innermost enclosing loop or switch only. To leave both, use a flag, a return from a function, or a goto to a label after the loops.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!