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 first attempt. In some situations it may be necessary to execute the body of the loop before the test condition is performed, such a situation the do..while loop is useful.

It is also repetitive control structure and executes the body of the loop once irrespective of the condition, then it checks the condition and continues the execution until the condition becomes false.

Do while loop

int main()
int i=1, sum=0;
printf("sum of the numbers upto 10 is %d",sum);

Run Example >

< Previous Next >

Privacy Policy Terms of Service About
Creative Commons License
This work is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License.