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

first it checkes the main function i.e., fn()
int fn(7)
if(7==1||v==0) : this is false so the complier executes
the next if condition
if(7%2==0) : This is false so it executes the else
instruction
return fn(6)+3; :here we are again calling the fn
function .So the loop executes till the 7 becomes 1
After this the first if condition is true so it rerurns 1
to the function fn(1)+3

so the answer is 1.

Is This Answer Correct ?    0 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I find the modification date of a file?

1287


Why is python slower than c?

1089


What is #define?

1114


A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

1202


Write a program to check palindrome number in c programming?

1018


how we can make 3d venturing graphics on outer interface

4832


What does a function declared as pascal do differently?

1129


What are structural members?

1010


What does %p mean?

1087


What is the size of array float a(10)?

1143


Can we use any name in place of argv and argc as command line arguments?

1073


What is meant by recursion?

1052


Can we use visual studio for c?

1096


How can I delete a file?

1067


What do you understand by normalization of pointers?

1059