0
C #preprocessing
Why the result =16? #include <stdio.h> #define sqr(x) x*x int main (){ int x=16/sqr(4); printf ("%d", x) ; }
3 Réponses
+ 5
You can think of #define as "find and replace", it just substitutes an expression in the code with another.
16/4*4 = 16
You can try this:
#define sqr(x) (x*x)
+ 3
make sure when defining macros, each reference to a variable is in parenthesis. It can lead to unexpected output
https://code.sololearn.com/c385BV6bS3gg/?ref=app
+ 2
Thank you guys for explanation, I've got it