Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

difference between while loop and Do... While Loop

0 votes
asked Feb 21, 2018 by anonymous

2 Answers

0 votes
answered Feb 21, 2018 by asdf
while(expr){
action();
}
executes action as long as expr holds true.

do {
action();
} while(expr);
does action once and if expr is true afterwards, does it again, and again ... until expr is false.
 

So
do{action()}while(expr);
is short for writing
action(); while(expr) { action(); }
0 votes
answered Feb 25, 2018 by sai ramessh reddy gayam
in while loop condition or expression verifies first if the condition is true it executes the while block until condition becomes false.while loop is also called as entry condition loop or pre-condition checking loop.

whereas in do while loop first it executes once later it verifies condition if it is true in executes until condition fails(it  runs once without condition checking).

syntax for while loop:

while(expr)

{

statements;

}

syntax for do while loop:

do

{

statements;

}while(expr);
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...