In nested loops, the break command exits only from the loop in which it occurs and passes the control to the statement that follows the end of that loop.
Select one:
True
False
Correct Option :- True
Explanation :-
In looping, break is a keyword that is used to terminate the loop so that it can not iterate further. Let's take an example to understand the functionality break keyword.
int i;
for(i=0; i<=5; i++)
{
cout<<i<<"\t";
if( i==3)
break;
}
Output:- 1 2 3
So, when the if-condition is true(i==2), the loop will not continue further and control of the program will leave the loop. Similarly, in the nested loop, the break command exits only from the loop in which it occurs and passes the control to the statement that follows the end of that loop.
Get Answers For Free
Most questions answered within 1 hours.