Pages

Friday, July 31, 2020

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.

MATHS TABLE FOR GIVEN A NUMBER >>

No comments:

Post a Comment