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 |
You have to take 2 arrays of length 10. Input the values of array 1 from the user. Then copy the values of array 1 to array 2 in ascending order For example if user enters 9, 5, 6, 8, 1, 0, 2, 7, 4, 3 then copy the smallest element i.e. 0 first followed by 1, 2 and so
How compile and run c++ program in turbo c++?
What is name hiding in c++?
Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?
Explain the properties and principles of oop.
If you want to share several functions or variables in several files maitaining the consistency how would you share it?
What is a breakpoint?
When one must use recursion function? Mention what happens when recursion functions are declared inline?
Explain what is polymorphism in c++?
Why do we use vector in c++?
what is the size of this class class size { public: char data1; double d; int data2; char data3; double data4; short data5; }; please explain the padding for these double variables.
Difference between Overloading and Overriding?
35 Answers Appnetix Techno, GameLoft, HP, IBM, NIIT, Rohde and Schwarz,