Unconditional Statements-Do while Loop

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

previous topic - next topic
Go Down

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


Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification:
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview