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 / chandrakala

this program returns the result as

1.


because,
7 is not equal to 1 or 0 and it is not mod by 2. so it will
go to else condition .in that 7-1 is performed and it mod
by 2 so 6/2=3 it once again go to else 3-1=2 is enter in to
function 2%2\=0 so 2/2 is performed.now v is 1 so it
returns 1 as answer.

Is This Answer Correct ?    5 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does struct node * mean?

1073


Which one would you prefer - a macro or a function?

1138


What is string concatenation in c?

1145


What is the use of ?

1091


Why main function is special give two reasons?

1607


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

1097


How do I use strcmp?

1141


Describe explain how arrays can be passed to a user defined function

1169


The statement, int(*x[]) () what does in indicate?

1205


What is %s and %d in c?

1110


Is c object oriented?

1020


Explain how can I pad a string to a known length?

1257


provide an example of the Group by clause, when would you use this clause

2252


What is difference between structure and union with example?

1123


Why pointers are used?

1121