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

Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

1088


What is scanf () in c?

1067


What is the purpose of void pointer?

995


Why is it important to memset a variable, immediately after allocating memory to it ?

2011


What is the value of h?

995


What is the use of linkage in c language?

1018


Multiply an Integer Number by 2 Without Using Multiplication Operator

728


What is break in c?

995


What are derived data types in c?

1019


Is sizeof a keyword in c?

923


Calculate 1*2*3*____*n using recursive function??

1991


In a switch statement, explain what will happen if a break statement is omitted?

1008


Explain a pre-processor and its advantages.

1086


What is malloc calloc and realloc in c?

1230


C language questions for civil engineering

1670