Do While Statement in C


Do While Statement in C

The syntax of do while statement (loop) is as shown below,
do
{
        Statements;
}while(condition);

Do while loop is called as the exit control loop because the condition is checked after the loop gets executed.

In do while loop the statements within the loop gets executed at least once.

The loop keeps on executing until the condition becomes false.

The Flow chart for the do while loop is as follows,

do while loop 
Example Program:



Output:





We can see in the above program that even tough the condition is false the loop gets executed once.so only it is called as exit check loop.

In this program the statement with in the loop is executed then it checks the condition here the condition is false so it comes out of the loop.

Example program 2:



Output:





Thank you ...
Please show your support by subscribing to my post below...

Popular Posts