From the C language standard, section 6.5:
-----------------------
2 Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression.72) Furthermore, the prior value shall be read only to determine the value to be stored.73).
...
72) A floating-point status flag is not an object and can be set more than once within an expression.
73) This paragraph renders undefined statement expressions such as
i = ++i + 1;
a[i++] = i;
while allowing
i = i + 1;
a[i] = i;
--------------------------
The expression y=++a + a+++ --a+ ++a violates this restriction; a is being modified multiple times by the evaluation of the expressions ++a, a++, and --a, thus the behavior is *undefined*.
C does not guarantee that operands are evaluated from left to right (except for the &&, ||, ?:, comma, and function-call () operators), nor does it guarantee that the side effects from the ++ and -- operators are applied immediately after each subexpression has been evaluated. Thus, the actual result will vary depending on the compiler, optimization settings, surrounding code, etc.
Since the behavior is undefined, *any* result (including 16) is allowed.
Login to rate this answer.
Answer will Be 15 Not 16
++a means a=4
a++ means for the current evaluation a=4 and for next a=5
--a means a=3
and at last ++a means a=4
so p=4+4+3+4=15
and a=5 as Post ++ after the last value of A.
Login to rate this answer.
first check then say answer is 15... its 16..
Login to rate this answer.