What is the difference between a while statement and a do statement

A while statement checks at the beginning of a loop to see whether the next loop iterationshould occur. A do statement checks at the end of a loop to see whether the next iterationof a loop should occur. The do statement will always execute the body of a loop at leastonce.

Showing Answers 1 - 5 of 5 Answers

syntax of while is as :

while(condition)

{

}

In while statement,first condition is checked,if the condition is true then the statements within loop are  executed otherwise statements within loop are not executed.

syntax of do-while as :

do

{

}

while(condition);

In do-while statement,first the statements are executed then condition is checked,if the condition is true then only further the loop is executed otherwise not.

  Was this answer useful?  Yes

jackshon9

  • Jun 27th, 2011
 

In While loop first condition will be checked and if it is true then code inside condition will performed. While in Do..While loop first code is performed one time afterwords condition will checked.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions