+ 1
16 is the output of following code. Explain
#include<stdio.h> #define square (a) a*a void main() { int i=16/square(4) ; prints("%d", i) ; }
1 Respuesta
+ 1
coffeeunderrun suggested a good and necessary correction to the macro. More parentheses would be needed if you should call it with an expression like square(i+3). That would incorrectly expand to (i+3*i+3). It should be ((i+3)*(i+3)).
Here is a better definition:
#define square(a) ((a)*(a))