What is Break Statement in C?

Break Statement is use to terminate the flow of switch case and to come out of the switch case.

Where we use break statement. ?

We use break statement only in the two places in the program

Syntax:

	
    break;
    

Example of break statement:

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

	void main()
	{
		int i;
		clrscr();

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

		getch();
	}
    

Output

	
    1
    2
    3
    4
    5
    

In above example we are terminating the iteration after 5 number with help of break statement. It will only print the numbers before the termination condition.

Previous Continue Statement Next Goto Statement

Advertisement here

Share this Page.

Post Your Comment