#define square(x) x*x
i = 8/square(4);
printf("%d ",i );
square(4) will return 4 * 4 then
i = 8/ 4 * 4 = 2* 4 = 8.
Practice other questions on define too,as they used to always give a different answer to what we think.
In this code the compiler will do the mapping means the x*x will be placed at the position of square(x) in the main section
i=8/4 * 4
So the answer will be 8/4=2 * 4 =8 answer.
If in the code would have written like this then
#define square(x) (x*x)
The output would be 0
The following code will evaluate the expression as follows:
i=8/44, (Macro square returns xx hence 4*4).
Precedence of / and * operators are the same so execution occurs from left to right.
Since there is no brackets to define order of evaluation, execution takes place as follows
Final Ans i=8