int i= 1; printf("%d %d %d\n", i++,i++,i); | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

int i= 1; printf("%d %d %d\n", i++,i++,i);

Output is 2 1 3 but why 1 after 2

14th Jun 2020, 8:58 AM
Rahul Kumar
Rahul Kumar - avatar
5 Answers
+ 5
Dont use statement with side effects as function parameters because they order is compiler dependent and not defined by language standard (eg. on output on a compiler and another output on another compiler)
14th Jun 2020, 9:15 AM
KrOW
KrOW - avatar
+ 3
When you perform more than one operation in single line then it can produce any output. The output is compiler dependent actually in this case as said by KrOW .
14th Jun 2020, 9:21 AM
Hardik Sharma
Hardik Sharma - avatar
+ 1
Ok Thank you KrOW Hardik Sharma
14th Jun 2020, 9:25 AM
Rahul Kumar
Rahul Kumar - avatar
+ 1
👍🏻
14th Jun 2020, 9:27 AM
KrOW
KrOW - avatar
0
You're welcome
14th Jun 2020, 9:26 AM
Hardik Sharma
Hardik Sharma - avatar