0

please clear my confusion ? break statement

what happens when break statement is executed? where is control transferred now? inside of INNER FOR LOOP or inside of OUTER FOR LOOP or out of all loops for(outer loop) { for(inner loop) { if(condition) { break; } } }

28th Nov 2020, 9:54 AM
Bibek Pant
Bibek Pant - avatar
4 Réponses
+ 4
Bibek Pant , you break only the inner loop in your example. The outer loop will still run.
28th Nov 2020, 9:56 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 2
A break always breaks only the nearest loop
28th Nov 2020, 12:02 PM
Davide
Davide - avatar
+ 1
28th Nov 2020, 12:13 PM
Bibek Pant
Bibek Pant - avatar
0
Welcome 🤗
28th Nov 2020, 12:28 PM
Davide
Davide - avatar