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 a local reference?
given unsigned int ui1=3,ui2=7; what are the outputs of a)ui1 & ui2 b)ui1 && ui2 c)ui1 | ui2 d)ui1 || ui2 i also need the justification for the answers thank you
Is facebook written in c++?
What is dynamic and static typing?
write the code that display the format just like 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1
What is the difference between while and do while loop? Explain with examples.
Explain what happens when a pointer is deleted twice?
What is set in c++?
What is the limitation of cin while taking input for character array?
What does std :: flush do?
What is the difference between public and private data members?
Write any small program that will compile in "C" but not in "C++"?