I have defined a macro to find the square of a number.
#include<iostream>
#define square(x) x*x
using namespace std;
int main()
{
int a = square(2+3);
cout<<a<<endl;
}
The output in the above case is 11. I have replaced the expression in the brackets with (3+2) then also the output is 11. Similarly for (4+2) and (2+4) the output is 14.
I have replaced the '+'
with '*'
then it is giving the normal output like it calculated the expression in the brackets first and calculating the square of that.
Can any one tell me how to generalize the output like what is the order of execution?