- For the loop
- While the loophole
- do ... while loop
C do-while loop
in do - while loop it checks the condition at the bottom of the loop.
The do while loop statements is a post tested loop. Using the do-while loop, we can re-execute different parts of the statement. The do-while loop is mainly used in menu driven programs where the closing condition depends upon the end user.
We use do while loop mainly where we want to execute condition or loop at least once
do while loop is same as while loop but it has one exception, it executes the statements inside the body of do while before checkin the condition. on the other side, in while loop first the condition is checked and then the statements in while loop are executed. So you can say that if a condition is wrong in the first initial phase then do while will only work once, however while loop will not work at all.
C – do..while loop
Syntax of do-while loop || do while syntax :-
How does a do-While loop executes?
- Control comes in a do-while loop.
- The statements in the main part of the loop are executed.
- Updation happens.
- The flow goes on condition
- Condition is tested.
- If the condition is true, go to step 6.
- If the condition is wrong, the flow goes out of the loop
- The flow goes back to step 2.