![]() Let’s say we have a list of names and we wish to stop the loop when a particular name is found, the break statement can be used for. Let’s see how the break statement works for both for loops, while loops and nested for loops. It terminates the inner loop and goes on to the outer loop. When a break statement is used in a nested loop, the inner loop does not run anytime the specific condition is met. The break statement is used to terminate a loop abruptly, based on another condition.
0 Comments
Leave a Reply. |