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 / babita sharma
The answer would be
b.
11 Its teh recursive function.
Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Explain how functions are classified in C++ ?
What are associate containers?
What is srand c++?
What is polymorphism & list its types in c++?
Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;
What is code reusability in c++?
What is an undefined reference/unresolved external symbol error and how do I fix it?
Is c++ vector a linked list?
Can we declare a base-class destructor as virtual?
What is meant by iomanip in c++?
Describe about storage allocation and scope of global, extern, static, local and register variables?
How to tokenize a string in c++?
What is a c++ map?
Explain what data encapsulation is in c++?
Explain terminate() and unexpected() function?