Answers:
If you understand basic usage of a++, ++a, a--, --a, that is sufficient. Anything which requires further understanding of precedence is confusing, and should be avoided in actual code, as it will lead to ununderstandable/unmaintainable/buggy code.
Hi in the printf statement for increment or decrement operators, the evaluation is done from right to left.
Ex.
int i=10;
printf("%d %d",i,++i);
will give output as 11 11
At the same time the recent calculated value is assigned to the same variable.
int i=10;
printf("%d %d", ++i,++i);
The output is 12 12. FIrst RHS is evaluated to 11, previous one is evaluated to 12 and it's value is taken for the RHS i also.
Login to add comment