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:
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);

a) 10
b) 11
c) 1

Answer Posted / jagdish patel

you have wrong option
correct answer is 9


solution:-
v=7;
so v is not =1,0 and also v%2 is not 0;
so (v-1)+3;
(7-1) + 3
6 + 3
= 9

Is This Answer Correct ?    3 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are manipulators used for?

1101


Where Malloc(), Calloc(), and realloc() does get memory?

1056


What is c++ try block?

1047


Evaluate as true or false: !(1 &&0 || !1) a) True b) False c) Invalid statement

1188


Can the operator == be overloaded for comparing two arrays consisting of characters by using string comparison?

1082


Is it possible to use a new for the reallocation of pointers ?

1065


Differentiate between a constructor and a destructor in c++.

1019


What is a map in c++?

1214


Difference between pointer to constant and constant pointer to a constant. Give example.

1126


What's the "software peter principleā€?

1151


What are the two types of comments, and how do they differ?

1138


Why c++ does not have finally?

1085


How do you establish an is-a relationship?

1161


Is it legal in c++ to overload operator++ so that it decrements a value in your class?

1064


What are the advantages of using const reference arguments in a function?

1077