+ 5

Why the output is 7?

#include <stdio.h> #define sqr(x) x*x int main() { printf ("%d",sqr(3+1)); } https://code.sololearn.com/cp3QNF1nfpZI/?ref=app

17th May 2019, 10:37 AM
Hadjer
Hadjer - avatar
1 Respuesta
+ 10
x is replaced with "3+1". 3+1*3+1 = 7. ==> #define sqr(x) (x)*(x) ==> (3+1)*(3+1) = 16
17th May 2019, 10:43 AM
Anna
Anna - avatar