In a do-while loop, when is the condition checked?

  • Before executing the code block
  • After executing the code block
  • During the execution of the code block
  • It's not checked in a do-while loop
In a do-while loop, the condition is checked after executing the code block. This means that the code block will always execute at least once before the condition is evaluated. If the condition is true after the first execution, the loop will continue running; otherwise, it will exit. This makes do-while loops suitable when you want to ensure that a specific task is performed before checking the condition.
Add your answer
Loading...

Leave a comment

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