# define SQ(r) r * r
    int x = 2;
    int i = SQ(++x);
         printf("%d\n" ,i);

In the above code, how the result will be 16. If i give r * r * r, the result will be 80. how can it be possible. can anyone explain?

The text of a macro argument is used, not the value of the variable. So after expansion the statement is:

int i = ++x * ++x;

On top of being undefined behavior, that's probably not the logic you intended. Any expressions with side effects should be avoided as macro arguments:


int i = SQ(x);