While loop in C language by R4R Team

while loop is the Entry control loop in C language

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

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

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


program-

#include< stdio.h>
int main()
{
int i;
printf("Before For Loop\n");
i=0;
while(i< 10)
{
printf("Inside loop i=%d\n",i);
i++;
}
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 start with i=0 then run the while loop 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!