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


Please Help Members By Posting Answers For Below Questions

Explain how functions are classified in C++ ?

801


What are associate containers?

610


What is srand c++?

573


What is polymorphism & list its types in c++?

616


Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;

1499






What is code reusability in c++?

662


What is an undefined reference/unresolved external symbol error and how do I fix it?

593


Is c++ vector a linked list?

544


Can we declare a base-class destructor as virtual?

582


What is meant by iomanip in c++?

603


Describe about storage allocation and scope of global, extern, static, local and register variables?

727


How to tokenize a string in c++?

600


What is a c++ map?

658


Explain what data encapsulation is in c++?

566


Explain terminate() and unexpected() function?

622