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

What is default value of global variable in c?

1047


What is meant by preprocessor in c?

1070


What is union and structure?

1189


Does free set pointer to null?

1061


What is an auto keyword in c?

1146


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

1328


How can I run c program?

1232


Explain what is page thrashing?

1160


Explain indirection?

1179


What is structure in c language?

1237


What are the types of operators in c?

1100


What is infinite loop?

1131


What is omp_num_threads?

1133


What is the difference between far and near in c?

1121


What is the difference between int main and void main in c?

1235