closed by
584 views
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;
closed by

1 Answer

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:

Related questions

2 votes
2 votes
2 answers
1
srestha asked May 13, 2019
917 views
Can someone explain the output of this code? and what (char*) is doing actually?#include<stdio.h struct Ournode{ char x, y, z; }; int main() { struct Ournode p={'1', '0',...
0 votes
0 votes
0 answers
4