do-while and while both are loop or iteration in c language, But they are differently way of execute the loop.
do-while | while |
1. It is an exit loop. i.e. when we are exit from the loop then only the condition will be checked. If the condition is true then only the codes written with-in it will execute. |
1. It is an entry loop. i.e. when we are entered into the loop then the condition will be checked. If the condition is true then only the codes written with-in it will execute. |
2. Whatever the logic, the codes are written within a do-while loop must execute at least one time. |
2. The codes are written within a while loop execute as per the logic. |
3. “do-while” loop ends with a semi-colon sign(;) |
3. ”while” loop does not use any semi-colon (;). |
4. Syntax: do { ........ // codes as per logic ........ }while(<condition>); |
4. Syntax: while() { ........ // codes as per logic ........ } |