What will happen if the condition in a while loop is always true?

  • The code block will never execute
  • The code block will execute once
  • An infinite loop will occur
  • An error will be thrown
If the condition in a while loop is always true, an infinite loop will occur. The code block will keep executing repeatedly, and the loop will never exit. This can lead to the program becoming unresponsive, and it's essential to ensure that the condition in a while loop eventually becomes false to prevent infinite loops.
Add your answer
Loading...

Leave a comment

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