154 views
1 votes
1 votes
#include<stdio.h>

#define ADD(a,b)(a+b)

#define SQUARE(x)(x*x)

int main()

{

int x=2;

int y=3;

int z = ADD(SQUARE(x++),y);

printf("%d\n",z);

return 0;

}

What is the output of the above code snippet?

2 Answers

1 votes
1 votes

9

 This question is easy the only catch is in int z = ADD(SQUARE(x++),y); in this line .

Firstly it will take the value of 2 as it is and then increment so the value will be 2*3.

z=(2*3)+3 = 9.

0 votes
0 votes


#include<stdio.h>

#define ADD(a,b)(a+b)

#define SQUARE(x)(x*x)

int main()

{

int x=2;

int y=3;

int z = ADD(SQUARE(x++),y);        // here is the cache which is 1st time Square takes 2 and 2nd time give 3 means SQUARE(old x*updated x)= SQUARE(2*3) gives 6  then add(6+3)=9

printf("%d\n",z);

return 0;

}

So the answer is 9

Related questions

0 votes
0 votes
0 answers
1
Neelu Lalchandani asked Nov 2, 2022
343 views
Time Complexity in C will be O(n) right? and big omega (n) is also big omega (n^2), then why is c incorrect?
0 votes
0 votes
0 answers
2
1 votes
1 votes
0 answers
3
Souvik33 asked Oct 30, 2022
408 views
A hash function h maps 16-bit inputs to 8 bit hash values. What is the largest k such that in any set of 1000 inputs, there are atleast k inputs that h maps to the same h...
0 votes
0 votes
0 answers
4
Souvik33 asked Oct 30, 2022
345 views
A hash function h maps 16-bit inputs to 8 bit hash values. What is the largest k such that in any set of 1000 inputs, there are atleast k inputs that h maps to the same h...