Register | Sing In

New posts

Stacks in C programming Linked Lists in C programming File Input/Output in C programming Check prime numbers in C Programming C Programming Enumeration C Programming Union

Archives

2013-10 2013-09 2013-08

Break statement in C programming

August 25, 2013 Posted by: GPA Views: 658 2 comments

Sometimes we need to exit from from a loop immediately. For this we can use break statement and exit from the loop. The break statement is used in while loop, do - while loop, for loop and also used in the switch statement.

In this example you will see how you can use break statement. 

 

 

Example:

   

#include <stdio.h>
#include <stdlib.h>
//main function
int main(int argc, char *argv[]){
   int i;
   for(i=0;i<10;i++){
printf("%d ",i);
    if (i==5) break;//Used break to skip printing all values after the value 5
       
   }
   system("PAUSE");//delay
   return 0;
} 

Output

Break statement in C example

Download this example

2 Comments...

1. Stavr

August 12, 2013, 2:18 pm
Avatar

This article is good. Thank you

2. Stavr

August 12, 2013, 2:17 pm
Avatar

This article is good. Thank you

Leave a Reply

Please, Sing In to leave a Reply for this material.



Online Chat

LiveZilla Live Help

Popular posts

Function strtok in C programming Check prime numbers in C Programming C Programming Union Linked Lists in C programming File Input/Output in C programming C Programming Enumeration

RSS-subscribe

New materials

Subscribe