C Programming

break statement in c

The break statement in C programming has the followingtwo usages: When a break statement is encountered inside a loop, the loop is Immediately terminated and the program control resumes at the next Statementfollowing the loop. It can be used to terminate a case in the switch statement . If you are using nested loops, the break statement will stop the execution of the Innermost loop and start executing the next line of code after th block.
Syntax
The syntax for a break statement in C is as follows: break;

Flow Diagram of Break Statement:

Examples of Break Statement:

#include <stdio.h>
int main()
{
     int num =0;
     while(num<=100)
     {
        printf("value of variable num is: %d\n", num);
        if (num==2)
        {
            break;
        }
        num++;
     }
     printf("Out of while-loop");
     return 0;
}

Premium E-Books & Study Materials.

Access university-specific notes and programming guides. Download instantly to start studying.

Share Article :

TopperWorld
Prime E-Books.

Access complete study guides for programming and core CS concepts.

Recent Articles :

What Jobs Will AI Replace: Which Careers Will Grow in the Next 5 Years?
Java Most Asked Interview Question and Answer
Top 10 AI companies in India
How Generative AI is Transforming Programming
Top GITHUB Interview Questions and Answers