How can you prematurely terminate a while loop?

  • break statement
  • return statement
  • continue statement
  • exit statement
You can prematurely terminate a while loop using the break statement. When a break statement is encountered within the loop, it exits the loop prematurely, regardless of whether the loop's condition is still true. This is useful for stopping the loop when a specific condition is met.
Add your answer
Loading...

Leave a comment

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