Unconditional Statements-Do while Loop

Started by thiruvasagamani, Sep 22, 2008, 10:48 AM

Previous topic - Next topic

thiruvasagamani

Do-While Loop:

Syntax:

initialisation;
do
{
stmt 1;
stmt 2;
......
......
stmt m;
increment/decrement;
}
while(condition);
stmt n;

In following figure init means intialization,cond means condition,inc/dec means increment/decrement,st means statements




Rules for do-while loop:

Statements in do-while are executed repeatedly executed as long as condition is true.The moment condition is false,control goes out of do-while loop and statements outside the loop are executed.

It is post tested loop or exit tested loop that is condition si tested at the end of loop.Hence do-while loop is executed at least once.There is semicolon(;) after condition, it indicates that end of do-while loop.


NOTE:
Use for loop,while loop,do-while loop to execute a group of statements repeatedly until condition is false
Thiruvasakamani Karnan