Why it show output is 28 please explain any one | Sololearn: Learn to code for FREE!

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; }

c

4/17/2021 3:35:49 AM

rahul barhate

2 Answers

New Answer

+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));

+6

square() is a marco, not a function, so 28/square(4) = 28/4*4 = 6*4 = 24.