K
karthikbalaguru
Hi,
I have a query on the behaviour while loop
based on code snippet given below -
int main(void)
{
int x = 0;
int y = 1;
while (y=10,x++)
{
printf("x = %d\n",x);
x++;
}
printf("y = %d\n", y);
return 0;
}
This above code prints the output as follows
y = 10
But, if the while is written like ' while (y=10) ', then it
becomes as while(1) and keeps printing the value of
x continuously .
Hence, shouldn't while(b=10,a++) should also become
as while(1) and keep printing the value of x continuously ?
But, how does it give output as 'y = 10' .
Any ideas ?
Thx in advans,
Karthik Balaguru
I have a query on the behaviour while loop
based on code snippet given below -
int main(void)
{
int x = 0;
int y = 1;
while (y=10,x++)
{
printf("x = %d\n",x);
x++;
}
printf("y = %d\n", y);
return 0;
}
This above code prints the output as follows
y = 10
But, if the while is written like ' while (y=10) ', then it
becomes as while(1) and keeps printing the value of
x continuously .
Hence, shouldn't while(b=10,a++) should also become
as while(1) and keep printing the value of x continuously ?
But, how does it give output as 'y = 10' .
Any ideas ?
Thx in advans,
Karthik Balaguru