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
Answers were Sorted based on User's Feedback
Answer / babita sharma
The answer would be
b.
11 Its teh recursive function.
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / 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 |
Explain register storage specifier.
What is c++ code?
What is virtual methods?
Which is not a valid keyword a) public b) protected c) guarded
Explain virtual destructor?
How will you call C functions from C ++ and vice-versa?
0 Answers Agilent, Tavant Technologies, Thomson Reuters, Verifone,
What is the difference between an external iterator and an internal iterator?
What is a template in c++?
what you know about c++?
Tell me what are static member functions?
Explain explicit container.
Which of the Standard C++ casts can be used to perform a ?safe? downcast: a) reinterpret_cast b) dynamic_cast c) static_cast d) const_cast