Do While Loops
C++ do...while Loop Syntax
The do...while loop is a variant of the while loop with one important difference. The body of do...while loop is executed once before the test expression is checked.
The syntax of do..while loop is:
How do...while loop works?
The codes inside the body of loop is executed at least once. Then, only the test expression is checked.
If the test expression is true, the body of loop is executed. This process continues until the test expression becomes false.
When the test expression is false, do...while loop is terminated.
Flowchart of do...while Loop
Example 1: C++ do...while Loop
Output
Last updated