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...

compute the nth mumber in the fibonacci sequence?

Answer Posted / ravi kumar gupta

#include<stdio.h>
#include<conio.h>

void main()
{
int n;
void fib(int n);
clrscr();

printf("Enter any no.");
scanf("%d",&n);
clrscr();

printf("Hit any key to continue");
getch();
clrscr();
printf("Fibonacci of %d is \n");
fib(n);

getch();

}
void fib(int n)
{
static int x,y;
int temp;
if(n<=1)
{
x=0;
y=1;
}
else
{
fib(n-1);
temp=y;
y=x+y;
x=temp;
}
printf(" %d\n",x);

return;
}

Is This Answer Correct ?    10 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is it usually a bad idea to use gets()? Suggest a workaround.

1718


What is the need of structure in c?

1067


What are different types of operators?

998


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

1942


What is c basic?

1139


What is size of union in c?

990


the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b

2627


What is pointer to pointer in c?

1075


What are Macros? What are its advantages and disadvantages?

1106


Can you please explain the difference between malloc() and calloc() function?

1065


What are structure types in C?

1067


When the macros gets expanded?

1357


Why static variable is used in c?

998


What is volatile c?

970


What is realloc in c?

1032