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
Answer Posted / rajesh
b
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
What is a volatile variable in c++?
What is lambda expression c++?
What can I use instead of namespace std?
How did c++ get its name?
If dog is a friend of boy, is boy a friend of dog?
Explain bubble sorting.
What is the use of main function in c++?
How can you link a c++ program to c functions?
what are Access specifiers in C++ class? What are the types?
Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;
Can c++ do everything c can?
What are different types of loops in c++?
Give example of a pure virtual function in c++?
how to explain our contribution in the project?
Comment on local and global scope of a variable.