Computer Science, asked by nain31, 1 year ago

Difference between while and do while loop?

Answers

Answered by Anonymous
21
Hello Buddy!!

Answer :  · Only difference between these two loops is that, in while loops, test expression is checked at first but, in do...while loop code is executed at first then the condition is checked. So, the code are executed at least once in do...while loops..

#Thanks

FollowMe

Mark Me as Brilliant....
Answered by siddhartharao77
23

Short note on while loop and do-while loop:

(i) A while loops condition is checked before each iteration.

(ii) A do-while loops condition is checked at the end of each iteration.


(i) While is an entry controlled loop.

(ii) Do-while is an exit controlled loop.


(i) While loop - Since condition is checked first,statements may or may not  get executed.

(ii) Do-while loop - Since condition is checked later, the body statements will execute at at least once.


(i) While loop:

while(Expression)

{

// codes

}


(ii) Do-while loop:

do

{

//codes;

}

while(Expression);



Hope this information helps!

Similar questions