+ 1
How is while loop different from do while?
2 Answers
+ 6
A do while loop is garanteed to loop at least once, as the condition is checked at the end of the loop rather than at the beginning.
Also, because of that, you can modify the parameters of the condition in the loop before it is checked, which is handy if the condition is false at the beginning of the loop but you still want to loop anyway. For example:
int a = 0;
do {
cout << a << endl;
a++;
} while (a%4 != 0);
+ 5
in do while loop the condition is checked after the execution whereas in while loop first condition is checked then execition is done...
if in do while loop the condition is false yet it will execute the program once..



