In this article we will going to discuss about Break Statement of C in which following topics are included as
- Break Statement in C
- Use of Break Statement in C
- Example of Break Statement
Break Statement in C
Break statement is used inside ,loops and switch statements. Sometimes it turns into essential to come out of the loop even earlier than the loop condition becomes false. In this situations, break statement is used to terminate the loop. This declaration causes an immediate go out from that loop where this declaration is seems.
It is written as: break;
When break assertion(statement) is encountered, loop is terminated and the control is transferred to the assertion(statement) right away after the loop. The break declaration is commonly written in conjunction with condition. If break is written interior a nested loop structure then it causes go out from the innermost loop.
Example of break statement:
include<stdio.h>
int main()
{
int n;
for(n=1;n<=5;n++)
{
if (n==3)
{
printf ("I understand the use of break\n").;
break;
}
printf ("Number %d\n", n) ;
}
printf ("Out of for loop\n");
return 0;
}
Conclusion:
In this article we will try to explain break statement in detail , i hope after reading this article you have no any doubt remaining in this topic but still if you any doubt then feel free comment below.
