3 votes 3 votes closed as a duplicate of: Undefined Behaviour in C #include <stdio.h> int main() { int i = 8; int p = i++*i++; printf("%d\n", p); } Programming in C programming-in-c + – Khushal Kumar asked Jul 7, 2017 closed Apr 5, 2022 by Arjun Khushal Kumar 611 views comment Share Follow See all 3 Comments See all 3 3 Comments reply srestha commented Jul 7, 2017 reply Follow Share Same these are compiler dependent. 1 votes 1 votes Khushal Kumar commented Jul 7, 2017 reply Follow Share But, according to you, what should be the output though? what ways the output will be given by the compiler and how does the different compilers carry out the result? THANK YOU! 0 votes 0 votes srestha commented Jul 7, 2017 reply Follow Share read this https://gateoverflow.in/62411/undefined-behaviour-in-c 1 votes 1 votes Please log in or register to add a comment.
–2 votes –2 votes Answer is 72. postfix increment is left to right associatively and the precedence of order is postfix increment > multiplication. Step 1: i = 8 p = 8 * i++; Step 2 : i++ i=9 p = 8 * 9 Step 3: i++ i=10 p=72 print p Arnab Bhadra answered Jul 7, 2017 Arnab Bhadra comment Share Follow See all 3 Comments See all 3 3 Comments reply dd commented Jul 7, 2017 reply Follow Share It has undefined behaviour 1 votes 1 votes Bikram commented Jul 7, 2017 reply Follow Share yes, it is undefined. we can not say " postfix increment is left to right associatively " actually it depends upon C compiler to generate more optimized code . 0 votes 0 votes amitraj123 commented Apr 5, 2022 reply Follow Share Above answer is wrong. Answer will be compiler dependent. 0 votes 0 votes Please log in or register to add a comment.