What will happen if the break statement is used outside any loop or switch statement? 

  • The program will crash. 
  • It will skip the next statement. 
  • It results in a compilation error. 
  • It breaks out of the main function.
Using the break statement outside of a loop or switch will result in a compilation error. The break statement is meant to terminate the nearest enclosing loop or switch where it appears. If it's placed elsewhere, it won't make logical sense to the compiler.
Add your answer
Loading...

Leave a comment

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