The break statement : Break « Statement « C Tutorial






break statement can break any type of loop.

#include<stdio.h>

main(){

    int i = 0;
    while (1)
    {
        i = i + 1;
        printf(" the value of i is %d\n",i);
        if (i>5) {
           break;
        }
    }
}
the value of i is 1
      the value of i is 2
      the value of i is 3
      the value of i is 4
      the value of i is 5
      the value of i is 6








6.9.Break
6.9.1.The break statement
6.9.2.Breaking out of a for loop