C do…while Loop
What is do while loop?
How does do while loop works?
the body of the loop;
increment or decrement;
Example of Do while loop:
int a, mult=1;
printf("Enter a number: \n");
printf("Total number after multiplication: %d",mult);
The output of the above code will be displayed in the way below.
Enter a number:
Total number after multiplication: 50
Things to remember:
- In do while loop, the condition is checked at last.
- The do while loop executes the body of the loop at least one time even if the condition is false. The body of the loop executes more when the condition is true.
- Sometimes we also call do while loop as an exit controlled loop.