Ticker

6/recent/ticker-posts

C Language (Infinite Loop In C)

INFINITE LOOP IN C




The infinite loop's execution never terminate, because it's test condition will never completed/satisfy.

Let's have the following example...

#include<stdio.h>
#include<conio.h>
void main()
{
int i=0;
while(i <= 0)
{
printf("\n%d",i);
i++;
}
getch();
}

Program Explanation: In the above program, variable i start with zero and the test condition <=0.
The variable i decrements its value by, i-- statement.
As i variable value decreasing rather than increase therefore the test condition of above program will never satisfy/complete, so the loop become, infinite loop.












Post a Comment

0 Comments