Do-While Loop in C programming language

Do-While Loop
     This statement is used when we want to execute the body of the loop at least once.
general systex:

do
statement;
while(condition)
statement1;
            Test the condition at the end of the loop rather than at the beginning, as demonstrated by the for and while loops. (condition) can be any valid C expression. When the program encounter the do-while loop, The statement(s) are executed. The (condition) is evaluated. If it is TRUE, execution returns to step number 1. If it is FALSE, the loop terminates and the next_statement is executed.

ex:
#include <stdio.h>
main()
{
int i = 10;
do{
printf("Hello %d\n", i );
i = i -1;
}while ( i > 0 );
}
Previous
Next Post »