Want Explanation !

I have been submitting solution to this problem www.codechef.com/problems/PRPOTION/ ,when i use a macro to find maximum of two values it gives Wrong Answer but when i use a function max then it works. Why ?

Well you have done a small mistake in the macro you have to put it in the bracket i.e
#define max(a,b) (a>=b?a:b)
Since what macro does it it just replicates you code as soon as it gets max(x,y) by a>=b?a:b now you would expect it to solve your max(R,B) first evaluate it and then compare with G but this is not happening in fact what you compiler evaluates that expression is a>=b?a:b>g?a>=b?a:b:g and then give you a answer. I hope I made it clear.
Your Correct Code-http://ideone.com/DZvm0S


Oh! Thank you !