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
What do you mean by translation unit?
Can a constructor return a value?
What is problem with overriding functions?
What is data abstraction? How is it different from data encapsulation?
How do you declare A pointer to function which receives an int pointer and returns a float pointer
What is a syntax in c++?
What are shallow and deep copies?
Explain the different access specifiers for the class member in c++.
Is string an object in c++?
What parameter does the constructor to an ofstream object take?
Write about all the implicit member functions of a class?
What is this weird colon-member (" : ") syntax in the constructor?
What is operator overloading in c++ example?
What are the basics of local (auto) objects?
What is c++ & why it is used?