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
Answer Posted / 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 |
Post New Answer View All Answers
To what does “event-driven” refer?
Which coding certification is best?
What is the difference between *p++ and (*p)++ ?
Explain the register storage classes in c++.
Give 10 points of differences between C & C++.
How do you declare a set in c++?
Explain what are accessor methods?
Write some differences between an external iterator and an internal iterator?
What is the need of a destructor?
What is the c++ programming language used for?
Which bit wise operator is suitable for putting on a particular bit in a number?
How do you define a class in c++?
How compile and run c++ program in turbo c++?
Why is polymorphism useful?
What is oop in c++?