Break Statement in C Programming

Break Statement in C:
Sometimes, it is necessary to exit immediately from a loop as soon as the condition is satisfied.
When break statement is used inside a loop, then it can cause to terminate from a loop. The statements after break statement are skipped.
Syntax :

	break;

Figure :

break statement

Program :

/*  Program to demonstrate break statement.
Creation Date : 09 Nov 2010 05:32:33 PM
Author : www.technoexam.com [Technowell, Sangli] */

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

int main(void)
{
	int i;
	clrscr();
	for(i=1; i<=10; i++)
	{
		if(i==6)
		break;
		printf("%d",i);  // 5 times only
	}
	getch();
	return 0;
}

Output :
12345_

Leave A Comment

Your email address will not be published. Required fields are marked *