Break statement in C

Break statement in C

  • break statement is used to come out of the loop and to come out of the switch block.
  • break is also used in conjunction with functions and case statements.

Program to understand using break inside the loop.

#include<stdio.h>
void main()
{
  int i=1;
  do{
      printf("\t%d",i);
      i++;
      if(i>5); break; /* if i value is 6 terminate */
  }while(1);  /* this is infinite loop */
}

Output:

1 2 3 4 5
naveed08st
 

Click Here to Leave a Comment Below 0 comments

Leave a Reply: