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,887
  • 13
  • 73
  • 108

2 Answers2

4

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

Douglas Leeder
  • 50,599
  • 9
  • 90
  • 136
1

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

Constantinius
  • 32,691
  • 7
  • 72
  • 83