do while loop in C language by R4R Team

do while is called as Exit control loop because in do while loop, the condition is check after the loop runs.
-It is the only loop in C language which are run atleast 1 time.

Syntax-
do
{
increament/decreament;
}while(condition)

Example-
i=0;
do
{
i++;
}while(i< 10)

i=10
do
{
i--;
}while(i>0)


program-

#include< stdio.h>
int main()
{
int i;
printf("Before For Loop\n");
i=0;
do{
printf("Inside loop i=%d\n",i);
i++;
}while(i< 10);
printf("After Loop");
}


output-

Before For Loop
Inside Loop i=0
Inside Loop i=1
Inside Loop i=2
Inside Loop i=3
Inside Loop i=4
Inside Loop i=5
Inside Loop i=6
Inside Loop i=7
Inside Loop i=8
Inside Loop i=9
After Loop

-In this program, we run the do while loop start with i=0 then run 10 times.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!