0
break statement let u come out of the for loop only...or is it applicable in the while and other loops also?
6 Answers
+ 3
Sure, you can use it anywhere.
Although in a while loop you would (usually) terminate the loop when it hits a certain condition
+ 2
Yes, even the while, and even switch etc.
+ 2
ok
+ 2
p_palak
When the compailer read the break statement he at the same time exit the loop without doing anything else than exit the loop.
0
And what if the loop contains an if-else bock?
Will it come out of the if-else block or the loop?
0
okay..... thank u so much