Code in C language.
#include<stdio.h>
#define PRODUCT(x) ( x * x * x)
int main()
{
int i =5,k;
k = PRODUCT( ++i );
printf("i is :%d ",k);
return 0;
}
My Question is why i
is : 392
? According to me output should be 336
. (because 6 * 7 * 8 = 336
)
Am I really messed up here??
Preprocessed code will have
( ++i * ++i * ++i)
which have Lack of sequence point between the two execution on same variable resulting Undefined behaviour.