Evaluate:
int fn(int v)
{
if(v==1 || v==0)
return 1;
if(v%2==0)
return fn(v/2)+2;
else
return fn(v-1)+3;
}
for fn(7);
a) 10
b) 11
c) 1
Answers were Sorted based on User's Feedback
Answer / babita sharma
The answer would be
b.
11 Its teh recursive function.
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / jagdish patel
you have wrong option
correct answer is 9
solution:-
v=7;
so v is not =1,0 and also v%2 is not 0;
so (v-1)+3;
(7-1) + 3
6 + 3
= 9
| Is This Answer Correct ? | 3 Yes | 8 No |
Define inline function
What is the difference between a type-specific template friend class and a general template friend class?
What is switch case in c++ syntax?
What is ios flag in c++?
What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0
Is java the same as c++?
Is c++ still being used?
What is the Difference between "C structure" and "C++ structure"?
How do you sort a sort function in c++ to sort in descending order?
You're given an array containing both positive and negative integers and required to find the sub-array with the largest sum (O(N) a la KBL). Write a routine in C for the above.
Is turbo c++ free?
What is set in c++?