Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / abdur rab

The answer is 11

( 7 - 1 ) + 3 -> 11 = (8 +3)

( 6 / 2 ) + 2 --> 8 = (6 +2)

( 3 - 1 ) + 3 ---> 6 = (3 +3)

( 2 / 2 ) + 2 ----> 3 = (1 +2)

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define VARIABLE?

1114


How can you convert integers to binary or hexadecimal?

985


What is string function in c?

950


Explain the use of 'auto' keyword

1075


Define the scope of static variables.

1067


Why do we use pointer to pointer in c?

1027


what is the difference between class and unio?

2308


What are examples of structures?

1032


Where register variables are stored in c?

914


Write a program with dynamically allocation of variable.

1072


What is the difference between the expression “++a” and “a++”?

1168


How does placing some code lines between the comment symbol help in debugging the code?

945


Which programming language is best for getting job 2020?

989


Write a program to print fibonacci series without using recursion?

1070


Can you subtract pointers from each other? Why would you?

921