Break in c


When we want an exit from loop then we used a break statement in c. we can provide a specific condition if the condition matches then this exit from the loop.


Simple example of Break in C


#include <stdio.h>

#include<conio.h>

void main()

{

int i;

clrscr();

for(i=1;i<=5;i++)

{

if(i==4)

{

break;

}

printf(“Welcome %d\n”,i);

}

printf(“Exit from loop here”);

getch();

}



Output:
welcome 1
welcome 2
welcome 3
Exit from loop here