+ 4

Pls give explanation for the following

#define square(x) (x*x) int main() { int x,y=1; x=square(y+1); printf("%d",x); return 0; } The output of this code is 3

5th Jun 2019, 5:07 PM
Subathra
2 Respostas
+ 2
Basically macro code is replaced in preprocessing phase. So the square(y+1) becomes (y+1 * y+1) After that by operator precedence 1+1*1+1 gives result 3
8th Jun 2019, 6:12 PM
Shubham Tandale
Shubham Tandale - avatar
+ 4
1+1*1+1 1*1--> 1 1+1+1 - - > 3
5th Jun 2019, 5:20 PM
✳AsterisK✳
✳AsterisK✳ - avatar