Given i = 10, j = 5, k = 0
Lets see how line (5) k == MAX(i++, ++j); works..
- Macro will replace MAX(i++, ++j) with (i++)>(++j):(i++):(++j);
- line (5) becomes k==(i++)>(++j):(i++):(++j);
The order of evaluation will be [[k==(i++)]>(++j)]:(i++):(++j);
- Put the values, the condition becomes
- ((0==10)>6) -> 0>6 --> Condition returns false!
- So false part of ternary operator works (++j) = 7
printf("%d %d %d", i,j,k); prints 11, 7 ,0