Infinite Loops

Back - C Language Notes By Vivek Sir email: vivekdubey22@gmail.com (w) 9826424484

·        A loop that repeats indefinitely and never terminates is called an Infinite loop.

·        Most of the time we create infinite loops by mistake. However, this doesn’t mean that the infinite loops are not useful. Infinite loops are commonly used in programs that keep running for long periods of time until they are stopped like the web server.

Example 3:

int i = 1;

 

while(i=10)

{

    printf("%d", i);

}

 
Example 1:

short int i;

 

for (i = 32765; i < 32768; i++)

{

    printf("%d\n", i);

}

 

Example 4:

float f = 2;

 

while(f != 31.0)

{

    printf("%f\n", f);

    f =  f + 0.1;

}

 

 
Example 2:

int i = 1;

 

while(i<10)

{

    printf("%d\n", i);

}

 

Example 5:

int i = 0;

 

while(i<=5);

printf("%d\n", i);

 

Back - C Language Notes By Vivek Sir email: vivekdubey22@gmail.com (w) 9826424484