Infinite loop in C language by R4R Team

Infinte Loop is the loop where loop continously run, and chances of condition become false is 0.

Infinte loop in for loop:

for(i=0;i>=0;i++)
{
}

-In this, value of i is always greator then 0 so loop continue run.

Infinite Loop in while loop:
while(1)
{
}

-In this, while(1) refers as always true


program-

#include< stdio.h>
int main()
{
while(1)
{
printf("Inside Loop\n");
}
}


output-

Inside Loop
Inside Loop
Inside Loop
Inside Loop
Inside Loop
.
.
.
.
.
.

How stop infinite loop:
1. Try to avoid errors and check the condition correctly.
2. Use the break statement to break the loop.




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!