0

(Operator pre: * / %) Why 16?

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

18th Feb 2019, 1:52 AM
HD Satria
HD Satria - avatar
3 Answers
+ 2
16/sqr(4) = 16/4*4 Try this: #define sqr(x) (x*x) or: printf("%d", 16/(sqr(4))); this equal 16/(4*4)
18th Feb 2019, 5:07 AM
Игорь Яковенко
Игорь Яковенко - avatar
0
16/4*4=16 But, in operator precedence, * first then / then %. Does it should = 1? 16/4*4 => 16/(4*4).
18th Feb 2019, 6:23 AM
HD Satria
HD Satria - avatar