Break Statement C Programming

The break statement in C programming language is used to terminate loop and takes control out of the loop. We sometimes want to terminate the loop immediately without checking the condition expression of loop. The break statement is used with conditional if statement.

Use of break statement, change the normal sequence of execution of statements inside loop.

Syntax of break Statement

Control Flow of break Statement C Break Statement Control Flow Diagram
Use of break Statement
  • We can use break statement inside any loop(for, while and do-while). It terminates the loop immediately and program control resumes at the next statement following the loop.

  • We can use break statement to terminate a case in the switch statement.
If we are using break statement inside nested loop, then it will only terminate the inner loop from where break is executed.

C Program to show the use of break statement

#include <stdio.h>
#include <conio.h>

int main(){
     * Using break statement to terminate for loop
    int N, counter, sum=0;
    printf("Enter a positive number\n");
    scanf("%d", &N);
    for(counter=1; counter <= N; counter++){
        sum+= counter;
        /* If sum is greater than 50 break
           statement will terminate the loop */
        if(sum > 50){
            printf("Sum is > 50, terminating loop\n");
    if(counter > N)
        printf("Sum of Integers from 1 to %d = %d", N, sum);
Above program find sum of all integers from 1 to N, using for loop. It sum is greater than 50, break statement will terminate for loop.

Enter a positive number
Sum of Integers from 1 to 9 = 45
Enter a positive number
Sum is > 50, terminating loop