0

Possible Duplicate:
post and pre increment in c
Undefined Behavior and Sequence Points

here i want to know why this output comes?? Any one Can Explain me All in proper manner

#include<stdio.h>
   int main() {
   int a=5;
   printf("%d %d %d",a++,a++,++a);
   return 0;
   } 

the output of this program is like

In LINUX 7 6 8

Community
  • 1
  • 1
sam_k
  • 5,983
  • 14
  • 76
  • 110

2 Answers2

4

It's undefined - side effects are only guarantied to be completed at sequence points.

Douglas Leeder
  • 52,368
  • 9
  • 94
  • 137
1

We can't. This is completely compiler dependent in what order the arguments are evaluated.

Constantinius
  • 34,183
  • 8
  • 77
  • 85