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
What is default value of global variable in c?
What is meant by preprocessor in c?
What is union and structure?
Does free set pointer to null?
What is an auto keyword in c?
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?
How can I run c program?
Explain what is page thrashing?
Explain indirection?
What is structure in c language?
What are the types of operators in c?
What is infinite loop?
What is omp_num_threads?
What is the difference between far and near in c?
What is the difference between int main and void main in c?