# C do…while Loop

## What is do while loop?

There might arise certain situations where it could be necessary to execute the body of the loop at first.  We will execute the body of the loop before the condition is set. In such a situation, we can use do while loop. Do while loop is also known as an exit controlled loop.

## How does do while loop works?

Syntax:

initialization,
do{
the body of the loop;
increment or decrement;
}while(condition);
Flowchart:

## Example of Do while loop:

Code:

#include<stdio.h>
int main(){
int a, mult=1;
do{
printf("Enter a number: \n");
scanf("%d",&a);
mult=a*mult;
}while(mult<10);
printf("Total number after multiplication: %d",mult);
}

The output of the above code will be displayed in the way below.

Output:

Enter a number:
5
Enter a number:
10
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.
SHARE C do…while Loop