do-while loop

Using do-while loop we can repeat the execution of several parts of the statement. The do-while loop is similar to the while loop with one important difference. The body of do-while loop is executed at least once. Only then the test expression is evaluated.

The syntax of the do-while loop

do{
//code to be executed
}
while(condition);

Let’s see the example of do-while loop

#include<stdio.h>  
int main(){    
int i=1;      
do{    
printf("%d \n",i);    
i++;    
}while(i<=10);   
return 0;  
}

Output

1
2
3
4
5
6
7
8
9
10

Submit your review
1
2
3
4
5
Submit
     
Cancel

Create your own review

The Technical Funda
Average rating:  
 0 reviews