Pages

Wednesday, 9 May 2018

Break and Continue Statement in C


Break and Continue Statement in C


Hello all, I hope till now you must be impressed with the power of loops in C programming. Well today I will tell you about the two keywords which are used very frequently inside loops.
These two keywords are given below.

1. break
2. continue

Lets learn about them one by one.

Break Statement in C
It is the keyword which is generally used to break the execution of loop. Sometimes we want to terminate the loop after getting the desired results. In those conditions, break keyword serves our purpose. After encountering the break keyword, control of program shifts to the next statement after the loop. They are used very frequently in the odd loops.

Lets take one example for better explanation.


#include<stdio.h>

void main()
{
 int i;

 for(i=0;i<5;i++)
 {
  printf("%d",i);
  break;
  printf("This will not appear!");
 }

 printf("nOnly this will appear!");
}