explain the importance of break statement in a switch statement
Answers
Answered by
30
When it is executed, a break statement causes the flow of control to jump to the next line after the loop or switch to the body containing the break. ... When used with a Switch statement the break statement stops the control to fall through the ladder of case statements.
Answered by
15
The break statement in C programming has the following two usages −
When a break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop.
It can be used to terminate a case in the switch statement (covered in the next chapter).
If you are using nested loops, the break statement will stop the execution of the innermost loop and start executing the next line of code after the block.
Similar questions