4. Break and continue #
Created Tuesday 22 October 2019
Break and continue are used to alter the normal flow of the **for, while **loops and the switch statement. **break: ** This exits only the innermost loop where we are currently in. loop1{int a loop2{ int b break; loop3{int a } } }
the break here will not let loop3 execute for any iteration of loop2. No.of times run = a*b continue: This will skip execution of the code below continue and take the nearest current to the next iteration.
-
Be sure to do the increment step when using the continue statement in a while loop. In the for loop this is not required. Because increment statement is executed even if continue is used.
-
Read only about break and continue: http://www.cplusplus.com/doc/tutorial/control/