{
int i;
while(i=10)
{
printf("%d",i);
i=i+1;
}
return 0;
}
//explain how o/p obtained //
{
int i;
while(i=10)
{
printf("%d",i);
i=i+1;
}
return 0;
}
//explain how o/p obtained //
I do not know exactly what are you asking, probably about infinite loop?
while(i=10) // this is always true, use == in C/C++
it will always print 10 because every time i becomes 11(i=i+1) and then it becomes 10(while(i=10)) and then 10 gets printed…if you do this:
while(i=10)
{
printf("%d ",i);
i=i+1;
printf("%d ",i);
}
output; 10 11 10 11 10…
and program will not terminate as while condition is always true(constant positive value of i)…
i mean while(i=10) true then printing 10 and then incrementing i=i+1 i.e now i=11 and then going back to while(i=10) here what happens whether i=11 or 10 but o/p is printing 10 infinitely please explain me this