The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
Though break statement comes under decision-making statement, its most oftenly using in looping. One can use the break statement to break out from a loop or switch statement. When break is executed within a loop, the loop ends immediately, and execution continues with the first statement following the loop.
The following flowchart will clearly demonstrate how break statement works
Let us write a C program to demonstrate break statement.
#include <stdio.h> //header file section
int main()
{
int a;
for(a = 1;a <= 5;a++)
{
if(a == 4)
{
break;
}
printf("%d ", a);
}
return 0;
}
The loop will be terminated immediately, when a variable a = 4 is encountered.
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019