answersLogoWhite

0

Can you Compare while and do-while?

Updated: 8/17/2019
User Avatar

Wiki User

14y ago

Best Answer

The 'while' statement evaluates its expression at the beginning of the loop, while a 'do while' statement evaluates its expression at the end of the loop. The 'while' statement might execute no times. The 'do while' statement will execute at least one time. It depends on what you want to do, and on how you want to use the side effects, if any, of the expressions in the expression. (Before or after)

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

A while() loop evaluates the conditional expression before entering the loop for the first time. If the conditional expression evaluates false, the loop does not execute. If the conditional expression evaluates true, the loop begins to iterate, evaluating the conditional expression before starting a new iteration.

A do...while() loop evaluates the conditional expression at the end of the first loop. and is therefore guaranteed to enter the loop at least once. If the conditional expression evaluates true, the loop begins to iterates, re-evaluating the conditional expression at the end of each iteration.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you Compare while and do-while?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between while dowhile?

While: If we can use while statement it will check the condition then proceed further loop statement.DoWhile: If we use dowhile, first execute loop statement then check the condition.


List out the differences between while and dowhile statement?

The do ..while loop is executed at least once, whereas the while loop may not be executed even once.


What is a dowhile statement in C programming?

"do statement while (...);" is a loop which does at least one iteration even if the condition after while is false. When, for instance, "while(...) statement" does not iterate at all if the condition after while is false.


Is a DOWHILE loop more flexible than a dountil loop?

No, they are equivalient. DO something WHILE condition; does the same thing as DO something UNTIL NOT condition;


What is difference between while and dowhile?

the test condition will be checked first after wards the body of the loop will be excuted in while statement and the the do while statement represented the body of the loop will be executed first and then the test condition will checked next


What is unique about a DOWHILE loop?

A DO-WHILE loop will always execute at least one iteration of the loop body. This is because the condition that controls the loop comes at the end of the loop, rather than at the beginning as per a WHILE or FOR loop.


Which is faster to find factorial whether recursive or dowhile?

recursion is always slower than iteration


How does the effect of alcohol while boating compare to its affect while on land?

Slightly more when on a boat


How does the affect of alcohol while boating compare to its effect while on land?

Slightly more when on a boat


How does the effect of alcohol while boating compare to effect while on land?

The effect is increased while boating


Can I compare prices of 50 inch TVs online?

You can compare 50 inch television on several websites. I would suggest walmart.com and amazon.com. They give you the ability to compare while reading reviews.


What animal is Edward compare to while hunting?

a mountain lion