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 / rajesh
b
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
Is python written in c or c++?
Why do we need c++?
Given the following seqment of code containing a group of nested if instructions: y = 9; if ((x==3) || (x == 5)) y++; else if (x == 2) y *= 2; else if (x == ) y-= 7; else y = 8; if the value of x is 4 before the nested IFs are executed, what is the value of y after the nested IFs are executed?
What is the best c++ compiler?
Must accepts "Maestro Cards" Tax for bike should be less than 15 Total number of lanes is more than 10 Must provides monthly pass Write a method: boolean isGoodTollBridge(String[] cardsAccepted, String[] tollTax, boolean hasMonthlyPass, int numberOfLanes); String[] cardsAccepted A String array of names of card types accepted for payment of toll tax, it can be null if the toll does not accept any card String[] tollTax A String array of toll tax chart (say “Train : 300â€Â,â€ÂBullCart : 10â€Â) boolean hasMonthlyPass This parameter defines whether there is any monthly pass available or not int numberOfLanes This parameter defines the number of lanes for each side
What do you mean by delegate? Can a user retain delegates?
Where and why do I have to put the "template" and "typename" keywords?
What is binary object model?
Why should you learn c++?
What do the keywords volatile and mean mutable?
What are the advantages of early binding?
Do you know the use of vtable?
What are the extraction and insertion operators in c++? Explain with examples.
How are Structure passing and returning implemented by the compiler?
What is ios :: in in c++?