saving . . . saved Increment operator has been deleted. Increment operator has been hidden .
Increment operator
Title
Question
Is there any Exemption association and precedence rules for using pre and post increment decrement operators(++, --) in an expression or printf() funtions. kindly explain with sample expressions. 

C-and-Cpp General None min None sec 29-02-20, 11:35 a.m. DhivyaRathinasamy

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.
29-02-20, 11:56 a.m. bhaskar76


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.
29-02-20, 4:02 p.m. gsivakamasundari


Log-in to answer to this question.