-4

Possible Duplicate:
Undefined Behavior and Sequence Points

the output of the programme

#include<stdio.h>
main()
{

 int i = 10;
 printf("%d %d %d\n", ++i, i++, ++i);

}

is 13 11 13. Can someone please explain this ?

Community
  • 1
  • 1
Suraj Menon
  • 1,456
  • 2
  • 27
  • 43

1 Answers1

3

It's the oldest question ever. Why do people find this so fascinating?

This is undefined behavior; you're relying on side-effects without a sequence point between modifications.

unwind
  • 378,987
  • 63
  • 458
  • 590