C TutorialLesson 17Free preview
C Break/Continue
This lesson is part of C · All levels
Summary
The break command removes the program from the repeat or switch once a certain condition is met, while continue jumps through the rest of the running iteration and straight to the next iteration. Both allow for more subtle control of the loop loop without having to wrap the entire logic in additional conditions. Break is useful for stopping early, while continue is suitable for passing certain cases. Overuse of both can make programming difficult to read.
Key points
- Break off the loop or switch and exit the structure
- Continue through the rest of the iteration code and then proceed to the next iteration
- Break in the switch prevents fall-through between cases
- Overuse makes the programming process difficult to understand
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.