C program break statement in for loop

C Programming Language Loop control in C Language (Article) Loop control in C Language (Program)

862

Program:

#include <stdio.h>
void main ()
{ 
int a =  0 ; 
while( a < 100 )
{
	printf("value of a: %d\n", a);
	a++;
	if( a == 50 )
	{ 
	 break;
	}
 }
 
}

Output:

value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
Press any key to continue . . .

Explanation:

This will print 10 to 16 after that break will terminate the loop. When the break statement is encountered inside a loop, the loop is immediately terminated, and program control resumes at the next statement following the loop.


This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.