Menu

Break Statement In C

 

The break statement is frequently used to terminate the processing of a particular case within a switch statement. 

  • To exit a group based on a condition, you can use break statement.
  • The break statement terminates the execution of the nearest enclosing do, for, switch, or while statement in which it appears. Control passes to the statement that follows the terminated statement.
  • The break statement is frequently used to terminate the processing of a particular case within a switch statement. 

Example

     #include<stdio.h>
     main(){
      for(i=0;i<10;i++){
       printf("%d",i);
       if(i==5){
         break;
       }
      }
     }

Output

      0 1 2 3 4 5