Main difference between using a while statement and a do-while statement
The main difference between a While statement and a Do...While statements that the condition is evaluated after the statements are executed in a Do...While statement. Therefore a Do...While statement always runs at least one time even if Condition does not match inside while condition in loop.
The main difference between a While statement and a Do...While statements that the condition is evaluated after the statements are executed in a Do...While statement. Therefore a Do...While statement always runs at least one time even if Condition does not match inside while condition in loop.
while(Condition)
{
statement.
}
Sample code for Do-while statement..
Do
{
statement.
}While(Condition)
Sample code for while statement..