Write a function to accept an array and return it after filling it with Fibonacci terms.
Answers
Answered by
0
#include<stdio.h>
#include<conio.h?
int fibo(int n);
void main()
{
int l,i;
int fibonacci[50];
clrscr();
printf("enter the limi: ");
sccanf("%d",&l);
for(i=0;i<l;i++)
fibonacci[i]=fibo(i);
for(i=0;i<l;i++)
{
printf("%d",fibonacci[i]);
printf("\n");
}
getch();
}
int fibo(int n)
{
if(n<=1)
return n;
else
return fibo(n-1)+fibo(n-2);
}
as you didnt mentioned any specific language i have chosen to write in c programming language and the function used is recursive function
#include<conio.h?
int fibo(int n);
void main()
{
int l,i;
int fibonacci[50];
clrscr();
printf("enter the limi: ");
sccanf("%d",&l);
for(i=0;i<l;i++)
fibonacci[i]=fibo(i);
for(i=0;i<l;i++)
{
printf("%d",fibonacci[i]);
printf("\n");
}
getch();
}
int fibo(int n)
{
if(n<=1)
return n;
else
return fibo(n-1)+fibo(n-2);
}
as you didnt mentioned any specific language i have chosen to write in c programming language and the function used is recursive function
Similar questions
Math,
9 months ago
Computer Science,
1 year ago
Math,
1 year ago
Science,
1 year ago
Math,
1 year ago