in C/C++ break statement is used to terminate the loops execution , switch case execution from the subsequent execution.
Syntax of Break Statement
break ;
Example 1:
#include #include int main() { int i; for(i=1 ;i<=10 ; i++) { if (i==5) break; printf(" \n %d",i); } return 0; }
In above example if we not use break statement then its display the number 1 to 10 but as we put the break statement in the body of loop after the IF statement which check the value of i if 1=5 then its execute the break statement other wise its execute the printf statement. When i assigned the value 5 then break statement execute and control is transfer outside the loop structure with checking the next value of i.
Declaring and Initializing Local Variable in C
Declaring and Initializing Global Variable in C Language
Printf Function In C Language
Sacnf Function In C Language
for Loop in C Language
While Loop in C Language
Do While Loop in C Language
Switch Case Statement IN C
IF -Else Statement IN C
Break Statement IN C /C++
User Define Function IN C /C++
Cout/Cin Function IN C /C++
Array IN C /C++
Two Dimensional Array IN C /C++
String In IN C /C++
Pointer In IN C /C++
Const and volatile keyword IN C /C++
Class and Object in C++
Function Over Loading in C++
Character Array In C++
Constructor in C++
Operator overloading in C++
Function Templates in C++
ATM Sample Project In Simple C Language
Find Area of Shape Using Function In C++