Break Statement

The break statement is used to break the control in the loops. Sometimes it is necessary to exit immediately from a loop as soon as the condition is satisfied.

When break statement is used inside a loop, then it can cause to terminate from a loop. The statement after break statement is skipped.

Syntax :-
    Break; Ex :
  while (condition)

Flow chart for break statement


Difference between if and switch statement

If Statement Switch Statement
If is used to check multiple conditions at a time. Switch checks a single condition at a time.
If is used to understand if number of conditions are more. Switch is easy to understand even if number of conditions is more.
If provides a facility to use the nesting of the if loop. Nested switch is not popular as if else nested loop.
If uses and, or and not operator to verify or check the conditions. Switch generally checks unique i.e. single character or single integer values as its cases.