I am trying this peice of code :
for (i = 0; i <= 100; i *= (i = ++sqrt((double)i)))
printf ("%d ", i);
and I get the following error :
tp.c:10:33: error: lvalue required as increment operand
for (i = 0; i <= 100; i *= (i = ++sqrt((double)i)))
It works fine with this :
for (i = 0; i <= 100; i *= (i = sqrt((double)i) + 1))
printf ("%d ", i);
I am not sure why is this so? My guess is that ++ operator needs a variable to operate upon, it cannot operate on a result returned by a function. Is there a way to make the code work using ++ operator?