Break Statement in C/C++


Break statement is also a loop control statement. It is used to terminate the loop. As the break statement is encountered, the loop stops there and execute the next statement below the loop. It is also used in switch statement to terminate the case.

Here is the syntax of break statement in C language,

break;

Here is an example of break statement in C language,

Example

 Live Demo

#include <stdio.h>
int main () {
   int a = 50;
   while( a < 60 ) {
      if( a == 55) {
         break;
      }
      printf("Value of a: %d\n", a);
      a++;
   }
   return 0;
}

Output

Value of a: 50
Value of a: 51
Value of a: 52
Value of a: 53
Value of a: 54

Updated on: 24-Jun-2020

198 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements