-4

I am a beginner in c programming I am trying something, but not able to understand this properly

#include<stdio.h>
int main()
{
    int x=5,y=10;
printf("%d %d %d %d\n",x++,y++,++x,++y);
}
Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
best wishes
  • 5,789
  • 1
  • 34
  • 59

1 Answers1

2

This:

printf("%d %d %d %d\n",x++,y++,++x,++y);

Is not well-defined code. The reason is that in C, the order of evaluation of function arguments is not defined. So it could do the various increments in any order, and therefore we can't say what the output should be. The code is defective.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436