posted Aug 11, 2009, 8:04 AM by Thiyagaraaj M
updated Aug 29, 2011, 11:41 AM
2+3 and 5 are not equal In C
what is the output of the program?
Example Program:#define Square( X ) ( X * X )
void main( )
value1 = Square( 2+ 3 );
value2 = Square( 5 );
if ( value1 == value2 )
The Macro replaces the code when there is necessity of the code.From the above program, we can able to understand the usage of Macro.
The value of value1 = 11.
The value of value2 = 25.
When the code Square(X) (X*X) replaces,we get,
value2= 5 * 5
So, we come to a conclusion that 2+3 and 5 is not equal always.
And hence,the Macro should be used in appropriate situations,otherwise Macro will give wrong result.