rahul.6sept
Full Member level 5
- Joined
- Nov 17, 2006
- Messages
- 243
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,298
- Location
- Guwahati, India
- Activity points
- 2,889
Dear All,
the following code of c++ gives an output which I could not understand as how is this coming. Can someone help me understand it.
I calculated for MM_1 the output to be 84 but the output it gives to be is only 8. How it is calculating it?
Regards
the following code of c++ gives an output which I could not understand as how is this coming. Can someone help me understand it.
Code:
#include <iostream>
using namespace std;
#define MM_1(x,y) x*y
#define MM_2(x,y) (x*y)
#define MM_3(x,y) (x)*(y)
inline int MPLY (int x, int y){return x*y;}
int main(){
int a=3,b=4;
cout << "MM_1:" << MM_1(MM_1(a+1, b-1), a+b)<<endl;
cout << "MM_2:" << MM_2(MM_2(a+1, b-1), a+b)<<endl;
cout << "MM_3:" << MM_3(MM_3(a+1, b-1), a+b)<<endl;
cout << "MPLY:" << MPLY(MPLY(a+1, b-1), a+b)<<endl;
return 0;
}
Regards
Last edited by a moderator: