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 |
What is the difference between #import and #include in c++?
What is the last index number in an array of 100 characters a) 100 b) 99 c) 101
What you mean by early binding and late binding? How it is related to dynamic binding?
What is purpose of abstract class?
What is an adaptor class or Wrapper class?
What are function prototypes?
Is c++ a dying language?
Is c++ high level programming language?
When does a name clash occur in c++?
Can we run c program in turbo c++?
What is a string example?
What is the v-ptr?