When you say continue the outer loop I'm assuming you mean complete the loop that has the "outer" label. I would answer this question by using the process of elimanation. a) Incorrect. break outer; would break out of all of the nested loops and start the loop all over again. So the outer loop would never complete. b) Incorrect. break middle; will cause the inner loop to break out of the loop and execute the code starting with the line that's labeled "middle". c) Correct. continue outer will cause the code to continue with the next iteration of the loop and if this is placed here the outer loop would complete. d)Incorrect. continue outer works.
When continue is used, the code leaves the loop that the continue keyword is in and continues with the next iteration of the loop if no label is supplied. other wise it continues with the next iteration of the loop that has the label it uses. When break is used without a label it exits the loop that the break keyword is in and it executes the code after the end of the loop. If a label is used it does the same thing except it jumps to the line of code that has the label.
Hi there, I think answer is "a)break outer" because when y reaches 10 "break outer will be executed which means it will come out of outer loop. So no more execution as there is no statement after loop is finished. It is not true to say "When break is used without a label it exits the loop that the break keyword is in and it executes the code after the end of the loop. If a label is used it does the same thing except it jumps to the line of code that has the label. Actually it will come out of this outer loop with execution of "break outer".
Hello the break outer statement terminates the loop with outer label and comes out of the loop while continue outer terminates the current iteration and start with the next iteration till the for loop conditional statement returns true.
The answers are b) and c) (break middle and (continue outer); Ronnie is right about a) - this will break out of the outer loop completely. b) is correct because when y is 10, break middle; is called so therefore, it jumps back to the outer loop, thus incrementing x by 1. (so the middle loop goes through 10 iterations, then x is x + 1 - all the way up to 99). c) is correct for the same reason as b d) is not correct. (continue middle; seems to make an infinite loop).