The do Statement
The do statement is a loop statement with an exit test at the end of the loop. Here is the general form of the do statement
The do statement first executes statement. After that, it evaluates test. If test is true, then statement is executed again. Statement continues to execute repeatedly as long as test is true after each execution of statement.
This example also prints the integers from zero through nine:
A break statement can also cause a do loop to exit.
Last updated
Was this helpful?