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

What do you mean by translation unit?

611


Can a constructor return a value?

586


What is problem with overriding functions?

613


What is data abstraction? How is it different from data encapsulation?

545


How do you declare A pointer to function which receives an int pointer and returns a float pointer

693






What is a syntax in c++?

617


What are shallow and deep copies?

648


Explain the different access specifiers for the class member in c++.

556


Is string an object in c++?

666


What parameter does the constructor to an ofstream object take?

624


Write about all the implicit member functions of a class?

609


What is this weird colon-member (" : ") syntax in the constructor?

553


What is operator overloading in c++ example?

670


What are the basics of local (auto) objects?

644


What is c++ & why it is used?

600