0
HELP: C programming
Why will the following question produce 3, instead of 4? #include <stdio.h> #define square(x) (x*x) int main() { int x, y = 1; x=square(y+1); printf("%d\n",x); return 0; }
2 Respuestas
+ 1
#define is a macro, it will just replace square(expressions) by expression*expression. so
x=square(y+1)=y+1*y+1=1+1*1+1=3
if you want it to really calculate the square, use:
#define square(x) (x)*(x)
0
I'm saved, thank you John Robotane 😆