326 views

1 Answer

Best answer
2 votes
2 votes
The given program uses recursion and bitwise XOR and AND operators along with left shift operator which doubles the current value.

The initial call is : operation(12,15) and hence according to the code

12 XOR 15 = 3 and 12 AND 15 = 12.In the code , the result of AND is left shifted which is also 2nd parameter so 12 * 2 = 24.

So now operation(3,24) is called and hence :

3 XOR 24 = 27   and 3 AND 24 = 0 which is left shifted to get 0 * 2 = 0

So now operation (27,0) is called and now termination since 2nd parameter is 0 and we return x which is the 1st parameter which is 27 in our case.

So 27 is returned finally and hence D) is the correct option
selected by

Related questions

2 votes
2 votes
2 answers
2
atulcse asked Jan 15, 2022
662 views
Consider the following programint find (int n) { int a = 1; for (i = 1; i < = n; i ++) for (j = 1; j < = i; j++) for (k = 1; k <= j, k++) a = a + 1; ...
1 votes
1 votes
1 answer
3
Na462 asked Jan 8, 2019
1,402 views
#include <stdio.h>main (){unsigned x = -10;int X = 20;if (X x) printf ("Hello");else{ printf ("%d",x); printf ("Jello"); }}
0 votes
0 votes
0 answers
4
aimhigh asked Jan 8, 2019
1,235 views
#include<stdio.h>void main(){int p=-8;int i= (p++,++p);printf("%d\n",i);}