What is the difference/s of while looping and do while looping statements?

Recommended Answers

All 2 Replies

While checks the condition then perform the task if it's true,

do while do the task and checks the condition afterwards, if it's true then it will do it again

When the condition is checked. For a while loop the condition is checked before the body of the loop runs. For a do while loop, the condition is checked after the body of the loop runs.

In practice, this essentially means that the body of a do while loop will always run at least once, regardless of the condition.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.