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 happens if a pointer is deleted twice?
When does a name clash occur in c++?
Differentiate between a template class and class template in c++?
What is conditions when using boolean operators?
Declare a class vehicle and make it an abstract data type.
What is the this pointer?
Explain the concept of copy constructor?
Why do we need pointers?
Write a short code using c++ to print out all odd number from 1 to 100 using a for loop
Write about the role of c++ in the tradeoff of safety vs. Usability?
Explain how functions are classified in C++ ?
What are the advantages of using a pointer?
Describe new operator?
Explain linked list using c++ with an example?
What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack