C Program using the break statement


In this program, You will learn how to implement a break statement in c.


if (condition){
     break; 
}

Example: How to implement a break statement in c.

#include<stdio.h>

int main() {

   int i;
   for (i = 1; i <= 10; i++) {
       if (i == 6){
          break;
       }
       printf("%d \n", i);
   }
   printf("Exit From loop");

   return 0;
}

Output:

1
2
3
4
5
Exit From loop