0

If you are using nested loops (i.e., one loop inside another loop), the break statement will stop the execution of the innermost

PLZZ someone explain me this by an eg

5th Oct 2020, 8:46 AM
Anisha Arora
Anisha Arora - avatar
3 Answers
+ 2
If you add break statment inside inner loop then inner loop will stop its exicution
5th Oct 2020, 8:56 AM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 1
Put this inside Main method and play around by commenting the `if` block for(int i = 1; i < 6; i++) { for(int j = 1; j < 6; j++) { // without the `if` block, this was supposed to print // 5 rows by 5 columns. if(j == 4) { break; } Console.Write("{0} ", j); } Console.WriteLine(); }
5th Oct 2020, 9:07 AM
Ipang
+ 1
That means the outer loop still executes n only the only the execution of the inner loop is interferred
5th Oct 2020, 9:50 AM
Anisha Arora
Anisha Arora - avatar