+6

why output is 3 why why why

// why output is 3 why why why ??? #include <stdio.h> #define square(r) (r*r) int main() { int y = 1; printf("Area is %d\n", square(y+1)); return 0; }

c

5/11/2020 5:46:37 AM

Ashutosh k.

3 Answers

New Answer

+11

The macro is : square(1) (1+1*1+1) So according to operator precedence, multiplication has higher precedence than addition. So first 1*1 is evaluated then addition is done. So 1+(1*1)+1 = 1+1+1 = 3

+6

Thanks nova

+4

It will be calculate like this square(1) (1+1*1+1) So 1+(1*1)+1 = 1+1+1 = 3