+ 2
someone plz explain how this is resulting in 3
#include <stdio.h> #define square(x)(x*x) int main() { int x,y=1; x=square(y+1); printf("%d\n",x); return 0; }
4 Answers
+ 4
square(y+1) becomes (y+1*y+1)
And that becomes 1+1*1+1 which is 3.
So y+1 isnt evaluated but just placed in the spots where x stands.
+ 1
thanks
0
It goes like this
1. Substituting in the function.
2. Substituting the values.
3. evaluation.
So according to the operator precedence first multiplication will be done and then addition.