Articles‎ > ‎Technical Articles‎ > ‎

### 2+3 and 5 are not equal In C

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( )
{
int value1,value2;
value1 = Square( 2+ 3 );
value2 = Square( 5 );

if ( value1 == value2 )
printf("Equal");
else
printf("Not Equal');
}

Output:
Not Equal.

## <!-- google_ad_client="pub-1880930424339742"; google_ad_host="pub-6693688277674466"; google_ad_width=728; google_ad_height=90; google_ad_format="728x90_as"; google_ad_type="text_image"; google_color_border="FFFFFF"; google_color_bg="FFFFFF"; google_color_link="000000"; google_color_url="0033CC"; google_color_text="444444"; //--> Description:

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.

How ?
When the code Square(X) (X*X) replaces,we get,

Iteration 1:
value1= (2+3*2+3)
Therefore,value1=11.

Iteration 2:
value2= 5 * 5
Therefore,value2= 25.

## Conclusion:

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.