in Programming closed by
425 views
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);
}
in Programming closed by
425 views

3 Comments

Same these are compiler dependent.
1
1
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
0
1
1

1 Answer

–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

3 Comments

It has undefined behaviour
1
1
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
0
Above answer is wrong. Answer will be compiler dependent.
0
0

Related questions