-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,486
  • 3
  • 28
  • 50

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
  • 391,730
  • 64
  • 469
  • 606