The break statement 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
Example:
void main()
{
int expr = 10;
while (expr)
{
printf("%d",expr);
expr--;
if(expr == 5)
break;
}
}
Output:
109876