0 votes 0 votes closed as a duplicate of: Undefined Behaviour in C X=2; Y=++x * ++x * ++x ; Printf("%d",Y); In the above question, we have to use the final value of x or it will be evaluated seperately and then multiplied. Ex: Y= 3*4*5; or Y=5*5*5; Programming in C self-doubt programming-in-c output + – Ashish Roy 1 asked Apr 11, 2019 closed Apr 18, 2019 by Arjun Ashish Roy 1 584 views comment Share Follow See all 3 Comments See all 3 3 Comments reply eyeamgj commented Apr 11, 2019 reply Follow Share it is compiler dependent we cant assume the associativity in terms of increment nd decrement 0 votes 0 votes Ashish Roy 1 commented Apr 11, 2019 reply Follow Share Okay. Suppose it is a NAT, then what should be the answer. Or it is inside a program and for getting the output of the program value of Y is required then what must be the answer? 0 votes 0 votes eyeamgj commented Apr 11, 2019 reply Follow Share NOTHING LIKE THIS WILL BE IN GATE AS FAR AS I KNOW 1 votes 1 votes Please log in or register to add a comment.
0 votes 0 votes Since pre increment and pre decrement have right associativity. Pre increment and decrement operator have more precedence than multiplication operator. Therefore , In Y=(++x)*(++x)*(++x), evaluation is done as follows: SuvasishDutta answered Apr 18, 2019 SuvasishDutta comment Share Follow See all 2 Comments See all 2 2 Comments reply Arjun commented Apr 18, 2019 reply Follow Share Evaluation order is separate from the associativity order. Associativity only specifies the operands for the operators and when and how the operands are evaluated is independent of it. https://gateoverflow.in/62411/undefined-behaviour-in-c 0 votes 0 votes SuvasishDutta commented Apr 22, 2019 reply Follow Share Thanks @Arjun sir. I understood the concept. 1 votes 1 votes Please log in or register to add a comment.