differentiate between while() loop and do while () loop
Answers
Answered by
13
A while loop is a control flow statement that allows code to be executed repeatedly based on any given condition
and
Do..... while is used to execute a set of statements once and then repeat the statement only if the given condition is true
and
Do..... while is used to execute a set of statements once and then repeat the statement only if the given condition is true
sakshi5293:
hope it helps u
Answered by
10
Explanation:
- Both types of loops repeat a block of statements until some condition becomes false.
- The main difference is that in a while loop, the test-condition is tested at the beginning of the loop, and in a do-while loop, the test-condition is tested at the end of the loop.
- It is possible that the body of a while loop might not be executed at all.
- However, The body of a do-while loop is executed at least once since the test-condition for ending the loop is not tested until the body of the loop as been executed.
- While loop is an entry-controlled loop.
- The do-while loop is an exit-controlled loop.
Similar questions
Physics,
1 year ago