Infinite loop or endless loop in C
An infinite loop program is a thread that never ends stable in a "natural". Ending thread is exceptionally user or a break in software or hardware. Sample loops. The classic example for infinity.infinite loop using for loop:
#include "stdio.h"int main () {
for( ; ; ) {
printf("This loop will run forever.\n");
}
return 0;
}
infinite loop using do while loop:
#include "stdio.h"
int main ()
{
do
{
printf("This loop will run forever.\n");
}
while(1);
return 0;
}
infinite loop using while loop:
#include "stdio.h"int main ()
{
while (1)
{
printf("This loop will run forever.\n");
}
return 0;
}
Comments