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

Is c++ vector dynamic?

647


What is meant by entry controlled loop?

742


What is c++ namespace?

813


What is a node class in c++?

733


What are references in c++?

764






Where can I run c++ program?

700


Search for: what is pair in c++?

712


What is type of 'this' pointer? Explain when it is get created?

670


What is microsoft c++ redistributable?

699


What do you mean by inheritance in c++? Explain its types.

708


What is a manipulative person?

633


Write a program using display() function which takes two arguments.

702


Which ide is best for c++?

656


Do you know what are pure virtual functions?

735


Explain public, protected, private in c++?

658