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
Give the rules for variable declaration?
What does calloc stand for?
How do you determine the length of a string value that was stored in a variable?
What is function definition in c?
What's the best way of making my program efficient?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
What are the disadvantages of c language?
stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.
How can I find out if there are characters available for reading?
Can a pointer be volatile in c?
What is the newline escape sequence?
can anyone please tell about the nested interrupts?
Explain how do you determine a file’s attributes?
What language is lisp written in?
Which driver is a pure java driver