61.0k views
1 vote
If you want to stop a loop before it goes through all its iterations, the break statement may be used.

True False

1 Answer

7 votes

Answer:

True: If you want to stop a loop before it goes through all its iterations, the break statement can be used.

Step-by-step explanation:

break and continue statements are used to stop loop from it's normal execution.

If we use break statement, the program control moves to the next line outside loop.

i=0;

sum=0;

while(i<=50)

{

if(sum > 100)

break;

sum=sum+i;

i++;

}

But if we use continue statement, the program control moves to the beginning of the loop.

i=0;

sum=0;

while(i<=50)

{

if(i%2==0)

i++;

continue;

sum=sum+i;

i++;

}

User Maxfax
by
8.9k points