The macro functions

shubhadajs's Avatar, Join Date: Jan 2011
Newbie Member
Dear all
I have a doubt regarding the macro function.


#define SQR(x) (x*x)
main()
{
int a,b=3;
a= SQR(b+2);
printf("%d",a);
}

The above program gives output as 11.
And if I pass SQR(b+3), it gives o/p 15.

How?
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
3+2*3+2 is what you are getting when you expand the macro