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 the code in while loop that returns the output of given code?
will u please send me the placement papers to my mail???????????????????
How we can insert comments in a c program?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
Which one would you prefer - a macro or a function?
What does c mean before a date?
List the variables are used for writing doubly linked list program.
Write a code of a general series where the next element is the sum of last k terms.
How can I determine whether a machines byte order is big-endian or little-endian?
What is c language used for?
What is 1f in c?
Why doesnt long int work?
Can we access array using pointer in c language?
Why are algorithms important in c program?
What is %s and %d in c?