Infinite while loop Example 3

C Programming Language / Loop control in C Language

930

Program:

#include <stdio.h>
int main()
{
    int var =5;
    while (var <=10)
    {
       printf("%d \n", var);
       var--;
    }
    return 0;
}

Output:

-15563
-15564
-15565
-15566
-15567
-15568
-15569
 ...........
............
............
..........
infinite time
 

Explanation:

Infinite loop: var value will keep decreasing because of –- operator, hence it will always be <= 10.

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.