views:

59

answers:

1

If int var=20 then how

printf("%d %d %d", var--, ++var, --var); 

execution happens in C programming language.

+8  A: 

It is undefined behaviour because var is modified several times without a sequence point in between. A sequence point would be, for example, a ;. The commas in parameter lists, do, however, not introduce sequence points, also the order in which the operands are evaluated is undefined (you could say, the code is doubly undefined ...).

Alexander Gessler
The order in which the operands are evaluated is not undefined, it is unspecified (there is an evaluation order, the implementation just doesn't have to document it nor to be consistent -- even between two executions of the same code line).
AProgrammer
You might want to consider the sequence of function parameter is being processed.
YeenFei