edited by
455 views

2 Answers

Best answer
7 votes
7 votes

#define is a Macro. What is the meaning of Macro is that, it will replace the value at compile time. It means that 

If we have defined 

#define FIVE 5

then in this for loop,

for(int i=0; i<FIVE; i++)

When compiler compile the above line then it will replace FIVE with 5. The point I want to make here that Program replaces Macro before starting the execution of the program.
Now comes to Question. 
#define Rec(a) a + a * a

At compile time expression a = 20 + Rec(a) * Rec(a + 1); will be replaced as
a = 20 + a + a * a * a + 1 + a + 1 * a + 1;  (lets evaluate it)
a = 20 + 3 + 27 + 1 + 3 + 3 + 1;
a = 58. 


Hence Program will print 58.
 

selected by
2 votes
2 votes

Rec(a)=a+a*a 

Rec(a+1)=a+1+a+1*a+1
After compilation this line a = 20 + Rec(a) * Rec(a + 1); become convert into this:-
                                                   a=20+a+a*a  *  a+1+a+1*a+1
for a=3
value of a will be printed 58.

 

Related questions

2 votes
2 votes
1 answer
1
0 votes
0 votes
1 answer
2
Markzuck asked Jan 10, 2019
522 views
Please explained detialed execution of this code, I am not getting how int stored in char, like we can interchange using ASCII but still cant store right?
1 votes
1 votes
0 answers
4