Posted By:
2 Jul, 2013 6:41 am PDT

Break statement in C++

What do you by break? What is the use of it?

Using a ‘break’ we can leave the loop even if the condition is not fulfilled. It can be used to end an infinite loop, or to force its end before its natural end.

For eg:


int main()


int n;


for(int i=n;n>i;i--)




break; ——————————

}     /* Once the break is encountered it immediately goes to  the next line after the loop. */

cout<<"\nEnd of loop"; //  ←——  



Was it useful?  

Please login to reply to this problem.