C program to print fibonacci series using function
#include<stdio.h>
#include<conio.h>
int fibo(int n);
main()
{
int a,i;
printf("Enter the number=");
scanf("%d",&a);
for(i=1;i<=a;i++)
{
printf("%d\t",fibo(i));
}
getch();
}
int fibo(int n)
{
if(n==0 || n==1)
return(1);
else
return (fibo(n-1)+fibo(n-2));
}
Output:
You may also read:
No comments:
Post a Comment