Evaluate the following:
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);
1) 10
2) 11
3) 1
Answer Posted / vinay
11 because it resrve every value in stack untill it become
1 then add all values.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
What is wrong in this statement? scanf(ā%dā,whatnumber);
What is the condition that is applied with ?: Operator?
What does nil mean in c?
diff between exptected result and requirement?
How can I manipulate strings of multibyte characters?
What is the difference between test design and test case design?
What Is The Difference Between Null And Void Pointer?
I need testPalindrome and removeSpace
#include
What is the difference between array_name and &array_name?
Difference between goto, long jmp() and setjmp()?
Explain the difference between null pointer and void pointer.
Is it better to use malloc() or calloc()?
How can I handle floating-point exceptions gracefully?
Did c have any year 2000 problems?