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 / jagdish patel
you have wrong option
correct answer is 9
solution:-
v=7;
so v is not =1,0 and also v%2 is not 0;
so (v-1)+3;
(7-1) + 3
6 + 3
= 9
Is This Answer Correct ? | 3 Yes | 8 No |
Post New Answer View All Answers
Which field is used in c++?
Are there interfaces in c++?
What is a class definition?
What is a c++ object?
What is a loop? What are different types of loops in c++?
What is c++ iterator?
what are the iterator and generic algorithms.
What is scope resolution operator in c++ with example?
How do we balance an AVL Tree in C++?
What is expression parser in c++
What is different in C++, compare with unix?
What is a sequence in c++?
What is fflush c++?
Describe the process of creation and destruction of a derived class object?
What is doubly linked list in c++?