0

In the following piece of C code, I would expect the printed output to be 5794. But when I compile it with GCC (7.5.0) the output is 5693. Why?

int main() 
{ 
    int x=20,y=35; 
    x=y++ + x++; 
    y= ++y + ++x; 
    printf("%d%d",x,y);
}
Tom Zych
  • 13,329
  • 9
  • 36
  • 53
ahzahraee
  • 17
  • 2

1 Answers1

2

this program has undefined behavior.which means you can't predict what will happen.

look for more information here Sequence_point

hanie
  • 1,863
  • 3
  • 9
  • 19