Do while loop in C Programming

In C programming language is Do while loop statements is one of the decision making and looping statements. The while loop makes a test of condition before the loop is executed. Therefore the body of the loop may not be executed at all if the condition is not satisfied at the very first attempt. On some occasions it might be necessary to execute the body of the loop before the test is performed. Such situations can be handled with the help of the do while loop statement. In C programming the general form of do loop is as follows –

do
{
        body of the loop
}
while ( test condition );

On reaching the do while  loop statement, the program proceeds to evaluate the body of the loop first. At the end of the loop, the test condition in the while statement is evaluated. If the condition is true, the program continues to evaluate the body of the loop once again. This process continues as long as the condition is true. When the condition becomes false, the loop will be terminated and the control goes to the statement that appears immediately after the while statement

Since the test condition is evaluated at the bottom of the loop; therefore, the do while loop statement is also called an exit controlled loop and hence the body of the loop is executed at least once.

yashan has written 70 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>