1. In While loop the condition is
tested first and then the statements are executed if the condition turns out to
be true.
In do while the statements are executed for the first time and then the conditions
are tested, if the condition turns out to be true then the statements are
executed again.
2. A do while is used for a block
of code that must be executed at least once.
These situations tend to be relatively rare, thus the simple while is more commonly
used.
3. A do while loop runs at least once
even though the the condition given is false
while loop do not run in case the condition given is false
4. In a while loop the condition is
first tested and if it returns true then it goes in the loop
In a do-while loop the condition is
tested at the last.
5. While loop is entry control loop
where as do while is exit control loop.
6. Syntax:
while loop :
while (condition)
{
Statements;
}
do while loop :
Do
{
Statements;
}while(condition);
tested first and then the statements are executed if the condition turns out to
be true.
In do while the statements are executed for the first time and then the conditions
are tested, if the condition turns out to be true then the statements are
executed again.
2. A do while is used for a block
of code that must be executed at least once.
These situations tend to be relatively rare, thus the simple while is more commonly
used.
3. A do while loop runs at least once
even though the the condition given is false
while loop do not run in case the condition given is false
4. In a while loop the condition is
first tested and if it returns true then it goes in the loop
In a do-while loop the condition is
tested at the last.
5. While loop is entry control loop
where as do while is exit control loop.
6. Syntax:
while loop :
while (condition)
{
Statements;
}
do while loop :
Do
{
Statements;
}while(condition);