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
What is c++ coding?
Explain rethrowing exceptions with an example?
What is guard code in c++?
How is computer programming useful in real life?
Explain what data encapsulation is in c++?
Write a program to add three numbers in C++ utilizing classes.
Explain the volatile and mutable keywords.
Is swift faster than c++?
Which coding certification is best?
How can you quickly find the number of elements stored in a static array?
Do class method definitions?
Describe delete operator?
Describe protected access specifiers?
What is a dangling pointer in c++?
What is namespace std; and what is consists of?