• closed by
1,322 views
0 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;

1 Answer

0 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:

Position:
Show:

Related questions

2 2 votes
2 2 answers
2.4k
2.4k views
srestha asked May 13, 2019
2,394 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',...
6 6 votes
1 1 answer
6.8k
6.8k views
Satbir asked Jun 1, 2019
6,790 views
#include<stdio.h #include<stdlib.h int main(void) { int maxLineCount = 500, maxCharCount = 500, index, j, count; char *line = NULL; size_t size; char *a[maxLineCount]; fo...
0 0 votes
0 0 answers
1.1k
1.1k views
srestha asked Apr 3, 2019
1,077 views
Can somebody explain this code line by line. I am unable to getand what will be it’s output?#include<stdio.h #include<stdlib.h void transpose(int n, const double *A, doub...
0 0 votes
0 0 answers
1.4k
1.4k views
Mk Utkarsh asked Nov 10, 2018
1,381 views
https://gateoverflow.in/45555/c-programming-predict-the-outputmain() { { extern int i; int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } print...