Break Program in C

The break statement is used to terminate the loop. In this program, if the value is equal to 6 then the loop will be terminated and the statement will be executed after the loop.

#include<stdio.h>
#include<conio.h>

void main()
{
int a;
clrscr();
a=1;

while(a<=10)
{
printf(“%d\n”,a);
a=a+1;
if(a==6)
break;
}

printf(“hello”);
getch();
}

Output:

break statement in c

Leave a Reply