Discussion :: C Preprocessor - Find Output of Program (Q.No.10)
|Wikiok said: (Apr 9, 2011)|
|It is only working because "+" has higher precedence, than "<". It will not work with &,|,^,&&,||.|
|Geetha said: (Feb 13, 2013)|
|In this program,(a > b ? a : b) is replaced by MAX(a, b), because in macros template is replace by macro expansion.
x=max(a>b?a:b). Here a=3+2=5;b=7+2=9.and 9>5.
So the answer is 9.
|Ajay said: (Jul 22, 2013)|
|MAX(a, b) (a > b ? a : b). Please can anyone explain how it evaluate value?|
|Vinay Guda said: (Jun 28, 2017)|
|Correct way to write this macro to avoid problems related to precedence is,
#define MAX(a,b) ((a)>(b)?(a):(b))
If you write this way you wont face problems when nest MAX.
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.