0
Explain the code please
3 Answers
+ 2
Am giving you one example hope after that you will understood much better.
Everything in the parenthesis is operated first from left to right it is read like this
Int k=-5;
Int a=(k++,++k);
a= (-4,-3);
a=-3;
Same in your case in if condition
int a=2;
if(a--,--a,a)
Values will be (2--,--2,a)
Means after decrement VALUE will be (1,0,0) so left value will be zero so if condition it will be false
0
Here's something probably help you see what's going on:
if ( printf ("%d\n", a--), printf ("%d\n", --a), printf ("%d\n", a) );
I replaced (a--, --a, a) with printf in it so you can see the value of a at that time. Please not that a-- will produce wrong result since it will be "post-decremented" after it prints out a--, the result should be if (1, 0, 0), 2 becomes 1 when it reaches comma. If you want to understand in more detail, try to understand how stack works first.