Here you will get to know about difference between while and do while loop.
Both while and do while loops are used to execute set of statements multiple times. But there are some differences between them in terms of syntax and working that I have discussed below.
Difference between while and do while Loop
while loop syntax
while(condition){ loop body; }
do while loop syntax
do{ loop body; }while(condition);
while loop | do while loop |
It is entry controlled loop. That means condition is checked at the start of loop body. | It is exit controlled loop. That means condition is checked at the end of loop body. |
Loop body is not executed if condition is false. | Loop body is executed once even if condition is false. |
Generally not used for making menu driven programs. | Generally used for making menu driven programs. |