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


Please Help Members By Posting Answers For Below Questions

Explain what is gets() function?

633


What is the difference between #include and #include 'file' ?

605


How can you convert integers to binary or hexadecimal?

616


Explain the difference between null pointer and void pointer.

673


What is non linear data structure in c?

577






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.

1983


What is the code for 3 questions and answer check in VisualBasic.Net?

1692


Explain is it better to bitshift a value than to multiply by 2?

718


Differentiate fundamental data types and derived data types in C.

618


How can I read/write structures from/to data files?

552


What is a c token and types of c tokens?

591


What is the scope of local variable in c?

578


How to explain the final year project as a fresher please answer with sample project

470


What is pointer in c?

742


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

669