0

Why it show output is 28 please explain any one

#include <stdio.h> #define square(x) x*x int main() { int i=(28/square(4)); printf("%d",i); return 0; }

17th Apr 2021, 3:35 AM
rahul barhate
rahul barhate - avatar
2 Respuestas
+ 7
Just for saftey, when declaring macros use parenthesis around the variables and around the whole thing if it helps: #define square(x) x*x /* to */ #define square(x) ((x)*(x)) a bit excessive, but it turns: int i = 28/4*4; /* into */ int i = 28/((4)*(4));
17th Apr 2021, 3:53 AM
Slick
Slick - avatar
+ 6
square() is a marco, not a function, so 28/square(4) = 28/4*4 = 6*4 = 24.
17th Apr 2021, 3:37 AM
你知道規則,我也是
你知道規則,我也是 - avatar