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 |
To which numbering system can the binary number 1101100100111100 be easily converted to?
What are the advantages of using a pointer? Define the operators that can be used with a pointer.
How do you invoke a base member function from a derived class in which you have not overridden that function?
What compiler was used?
What is data hiding c++?
How many ways can a variable be initialized into in C++?
What is the iunknown interface?
What is the difference between structures and unions?
What is class in c++ with example?
iam a fresher to Qt(GUI a c++ based framework software). i need to develop the basic applications on designer by drag and dropping mechanism...so pls send me the procedure to design applications?
Given a simple program designed to take inputs of integers from 1-1000 and to output the factorial value of that number, how would you test this program? You do not have access to the code. Please be as specific as possible.
Why can templates only be implemented in the header file?