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
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
explain what is an endless loop?
Array is an lvalue or not?
What is an identifier?
How do I swap bytes?
Write a program with dynamically allocation of variable.
Ow can I insert or delete a line (or record) in the middle of a file?
Why & is used in scanf in c?
What is self-referential structure in c programming?
plz let me know how to become a telecom protocol tester. thank you.
If the size of int data type is two bytes, what is the range of signed int data type?
What is the -> in c?
Explain how can I right-justify a string?
Explain the meaning of keyword 'extern' in a function declaration.
Which is best linux os?