Just the opposite.
All the operands are evaluated from left to right, and the right most
operand is returned as the value of whole comma expression.
But remember the operator precedence. Comma is lower than assignment.
So c=--a, b++ - c is equivalent to c=--a; b++ -c;
While c=(--a, b++ -c) is
but how comma is evaluated and the value assigned to variable 'c' is the
expression evaluated on the RHS of commais there any such rules in C ??
generally for comma separated value the compiler ignores all values to
the right of first comma.
eg. in above case c=--a,b++ - c;
the
the rule governs that in exprns on both the side gets evaluated
only if first exprns gives TRUE if 1st one gives FALSE then whatever
be 2nd exprn answer be FALSE
and in || 2nd side is not evaluated if 1st side replies with TRUE..
On Dec 13, 9:10 pm, siva viknesh sivavikne...@gmail.com wrote:
ya all the exprn is evaluated and left expr is assigned ..
On Dec 13, 9:21 pm, siva viknesh sivavikne...@gmail.com wrote:
#includestdio.h
int main()
{
int a=1,b=2,c=3;
c=--a,b++ - c;
printf(%d %d %d,a,b,c);
return 0;
}
the above code is perfectly valid and prints 0 3 0 ...
but
thanks a lot for your explanation:)
On Dec 14, 2:48 pm, sourabh jakhar sourabhjak...@gmail.com wrote:
answer will be -1
because the statement in while loop will never executed
as (+(+0)!=0)
this will be evaluated as false because zero is not equal to zero
and i is decremented in here but
int main()
{
int k = 5;
if (++k 5 k++/5 || ++k = 8);
printf(%d\n, k);
return 0;
}
for the above code output is '7' and not '8'...why??
int main()
{
int k = 5;
if (++k 5 k++/5 );
printf(%d\n, k);
return 0;
}
similarly for the above code output is '6' and not '7'...why??
--
You