What is the difference between while and do while statements


9/15/2019 12:22:20 PM

Likhitha Kande

4 Answers

New Answer


You can find your answer here https://techdifferences.com/difference-between-while-and-do-while-loop.html


"while" is pre - test, it check the condition first before executing the inside code , while the "do while" is post - test that it execute the code first then check the condition.


x = 1 example: while(x > 2){ display "hello" } output : (no ouput) because the condition is already false do { dipslay "hello" } while(x > 2) output : hello


while loop first check the condition then execute the code inside the loop do while first execute the code inside the loop then check the condition So do while execute once even the condition is false