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
Explain what is gets() function?
What is the difference between #include and #include 'file' ?
How can you convert integers to binary or hexadecimal?
Explain the difference between null pointer and void pointer.
What is non linear data structure in c?
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
What is the code for 3 questions and answer check in VisualBasic.Net?
Explain is it better to bitshift a value than to multiply by 2?
Differentiate fundamental data types and derived data types in C.
How can I read/write structures from/to data files?
What is a c token and types of c tokens?
What is the scope of local variable in c?
How to explain the final year project as a fresher please answer with sample project
What is pointer in c?
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.