Description :
Here the program for Fibonacci series in c.
Program:
#include
#includefib(int a);
void main()
{
int b,c,n,i;
//clrscr();
printf("enter the value for n");
scanf("%d",&n);
i=fib(n);
printf("\n %d",i);
getch();
}
fib(n)
{
if(n==0||n==1)
{
return n;
}
else
{
return (fib(n-1)+fib(n-2));
}
}
Output:
Fibonacci Series |
No comments:
Post a Comment