Break and Continue
C has "continue" and "break" keywords to either continue or exit from the loop. However "break" is also used with "switch" but here one thing to remember is that switch block is not a loop thus continue is not used with switch.
Continue is used to skip current block of statements for one iteration and to jump to the beginning of the loop for condition checking so that it can begin next iteration. Break however is to exit from the loop and directly go to the end of the loop. Here we have three diagrams for each type of loops to explain the control flow of "continue" and "break" in for, while and do-while loops.
For loop - Break/Continue
While loop - Break/Continue
Do While loop - Break/Continue
Here we want to mention one point is both continue and break works on the current/inner loop thus it will not work for the outer loop. This is a scenario when we have two or more nested loops and breaking from the inner loop then control will likely go to the end of inner loop only. It will not break from outer loops.
About our authors: Team EQA
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Free alt softwares