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

Does free set pointer to null?

1015


Explain what is a program flowchart and explain how does it help in writing a program?

1103


Are pointers really faster than arrays?

1036


Is this program statement valid? INT = 10.50;

1167


Differentiate between calloc and malloc.

1280


What is meant by realloc()?

1164


What are logical errors and how does it differ from syntax errors?

1308


What is the difference between array and pointer?

1036


How can I find the modification date of a file?

1293


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

2583


Wt are the Buses in C Language

3221


Write a program to swap two numbers without using a temporary variable?

1135


What does stand for?

1093


Define macros.

1283


What is the difference between strcpy() and memcpy() function in c programming?

1096