C Exercises
Home
'C' Exercises ▼
Basic C Programming
If-else Statements in C
Loops in C
Arrays in C
Pattern Programs in C
Series Programs in C
String in C
Switch-case in C
Functions in C
Pointers in C
Bitwise operators in C
File handling in C
Tricky Programs in C
Projects in C ▼
C Project-1
C Project-2
Java ▼
Java Introduction
Arrays in Java
Basic Java Examples
Generics in Java
Constructor in Java
OOP's Interview Questions
▼
What is Break Statement in C
Break statement is very useful to exit from any loop such as for loop, while loop and do while loop. When the break statement is encountered in the loop then the loop will stop running the statements and immediately exit from the loop.
Syntax of Break Statement in C :
Example program of break statement:
#include <stdio.h>
void main ()
{
int i;
for (i=1;i<=10;i++)
{
if (i==5)
{
break ;
}
else
{
printf ("%d " ,i);
}
}
}
In above program we have used break statement. When break statement encounter's program exit's the loop and it will print the following output:
No comments:
Post a Comment
If you have any doubts, please discuss here...👇