The break statement in C programming has the followingtwo usages: When a break statement is encountered inside a loop, the loop is Immediately terminated and the program control resumes at the next Statementfollowing the loop. It can be used to terminate a case in the switch statement . 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 th block.
Syntax
The syntax for a break statement in C is as follows: break;
Flow Diagram of Break Statement:
Examples of Break Statement:
#include <stdio.h> int main() { int num =0; while(num<=100) { printf("value of variable num is: %d\n", num); if (num==2) { break; } num++; } printf("Out of while-loop"); return 0; }