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

How do you write a program which produces its own source code as output?

1058


Is c++ based on c?

1021


Explain the difference between #include "..." And #include <...> In c?

981


what is the different bitween abap and abap-hr?

2213


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

2469


What is a structure and why it is used?

1134


Is exit(status) truly equivalent to returning the same status from main?

1007


What is 1d array in c?

1028


What is selection sort in c?

1014


What is a stream in c programming?

1078


How many levels deep can include files be nested?

1097


What is the argument of a function in c?

988


why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

1092


What is the maximum no. of arguments that can be given in a command line in C.?

1084


Why main is not a keyword in c?

1173