-1

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??

Grijesh Chauhan
  • 57,103
  • 20
  • 141
  • 208

1 Answers1

3

Preprocessed code will have

( ++i * ++i * ++i)

which have Lack of sequence point between the two execution on same variable resulting Undefined behaviour.

Dayal rai
  • 6,548
  • 22
  • 29