348 views
0 votes
0 votes
tokens passed to macros are treated as int, float or string?

1 Answer

0 votes
0 votes

Arguments to macros are simply passed as text, and after preprocessing

Your code become     printf("%f",ADD(5.50,5.50));
to
    printf("%f",5.50+5.50);
And now compiler considers them as double, addition is in double, and %f is for double hence prints double value.
Why%f is double?
https://stackoverflow.com/questions/4264127/correct-format-specifier-for-double-in-printf

Why 5.50 is double and not float?

https://stackoverflow.com/questions/4353780/why-floating-point-value-such-as-3-14-are-considered-as-double-by-default-in-msv

Related questions

2 votes
2 votes
1 answer
2
sid1221 asked Jul 18, 2017
1,533 views
# include <stdio.h># define scanf "%s GeeksQuiz"int main(){ printf(scanf, scanf); return 0;}(A) Compiler Error(B) %s Geeks Quiz(C) Geeks Quiz(D) %s Geeks Quiz Geeks ...
0 votes
0 votes
1 answer
3
Debargha Mitra Roy asked Apr 16
78 views
#include <stdio.h int main() { int a[3] = {1, 3, 5, 7, 9, 11}; int *ptr = a[0]; ptr += sizeof(int); printf("%d", *ptr); return 0; }(Assume size of int to be $2$ bytes.)T...