In a complex program with multiple nested loops, if James wants to exit out of all loops once a certain condition is met, which control structure or technique can he employ?

  • break statement
  • continue statement
  • goto statement
  • return statement
James can use the break statement labeled with the outermost loop to exit all nested loops when the condition is met. It will terminate the loop currently executing and any enclosing loops. Using return would exit the entire function, which might not be desired. continue and goto are not designed for this specific purpose.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *