answersLogoWhite

0


Best Answer

Yes. Break terminates only the innermost control structure, loop, switch, etc. If you want to break out of nested control structures, you can set a variable to induce a second break, or you can throw an exception.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Does break statement terminate only the inner loop in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are break and continue statement in c language?

Break is used to exit the closest loop. Continue will cause the program to go to the beginning of the loop. for(int x=0;x<10;x++) { //continue; for(int y=0;y<10;y++) { break; } } The break statement causes the inner loop to stop at the first iteration. If the continue statement was uncommented, the inner loop would never be executed because the program would jump back to the beginning(until x = 10 of course).


Difference between break and continue statements in wml?

Break statements:-its terminates the current while or for loop and continue the program execution from the statement following the terminated.NOTE:-note that it is wmlscript syntax error to use the break statement outside of while or a for statements.example;Breakstatement:Break;Continue statement:-this statement terminate execution of a block of statementin while or for loop and continues execution of loop with the next iteration.note that the continue statement does not terminate the execution of loop and also is wmlscript syntax error to use the break statement outside of while or a for statements.-> in while loop, it jumps back to the condition.-> in for loop,it jumpsto the update expression.syntax:continuestatement:continue;


How do you fix an infinite loop?

It comes from its name: it doesn't terminate, the user have to interrupt the program-run (in the worst case: power off the computer).The infinite loop is also used to program loops with non-easily-deterministically end-of-loop conditions.You write an infinite loop, such as for (;;) {statements}, and break out of the loop with the break statement when ready to terminate.


Can break statement be used without any loop?

The Break statement should generally get executed in some loop or switch statement. The below code will give compiler error. void main() { printf("12"); break; printf("14"); }


Compare break and continue statement?

Break - will force to terminate the loop you are in to the nearest outer block.Continue - will force to skip the rest of the code in loop and take next iteration.Break for example is not only limited to loop constructions, it is also used in switch statement in order to stop executing following cases (works as described above, jumps out of switch).

Related questions

What is purpose of break statement?

to terminate a loop.


What are break and continue statement in c language?

Break is used to exit the closest loop. Continue will cause the program to go to the beginning of the loop. for(int x=0;x<10;x++) { //continue; for(int y=0;y<10;y++) { break; } } The break statement causes the inner loop to stop at the first iteration. If the continue statement was uncommented, the inner loop would never be executed because the program would jump back to the beginning(until x = 10 of course).


Difference between break and continue statements in wml?

Break statements:-its terminates the current while or for loop and continue the program execution from the statement following the terminated.NOTE:-note that it is wmlscript syntax error to use the break statement outside of while or a for statements.example;Breakstatement:Break;Continue statement:-this statement terminate execution of a block of statementin while or for loop and continues execution of loop with the next iteration.note that the continue statement does not terminate the execution of loop and also is wmlscript syntax error to use the break statement outside of while or a for statements.-> in while loop, it jumps back to the condition.-> in for loop,it jumpsto the update expression.syntax:continuestatement:continue;


How do you fix an infinite loop?

It comes from its name: it doesn't terminate, the user have to interrupt the program-run (in the worst case: power off the computer).The infinite loop is also used to program loops with non-easily-deterministically end-of-loop conditions.You write an infinite loop, such as for (;;) {statements}, and break out of the loop with the break statement when ready to terminate.


Can break statement be used without any loop?

The Break statement should generally get executed in some loop or switch statement. The below code will give compiler error. void main() { printf("12"); break; printf("14"); }


Compare break and continue statement?

Break - will force to terminate the loop you are in to the nearest outer block.Continue - will force to skip the rest of the code in loop and take next iteration.Break for example is not only limited to loop constructions, it is also used in switch statement in order to stop executing following cases (works as described above, jumps out of switch).


How do you break a loop in a switch case statement?

using break; statement


How do you terminate in C language a loop?

The keyword "break" will immediately terminate the enclosing loop. Otherwise using conditions in the loop will terminate the loop once the condition becomes false. eg int i = 0; int b =0; for(i ; i < 3; i ++){ b++; } Will increment i and b on each iteration. The loop will terminate when i >= 3 (when the condition i < 3 becomes false).


What is the different between break and continue?

The break statement exits out of the smallest containing loop or switch-case statement. The continue statement transfers control to the next iteration of the smallest containing loop statement.


What is the purpose of break statement in c?

The break statement exits control of the innermost for, while or do-while loop, or switch statement.


Break statement in while loop?

Perfectly legal.


What is break in c?

The break statement is used to exit a loop or switch-case.