Program to calculate fibonacci series using function in c
#include "stdio.h"
main()
{
int n;
printf("Enter the number range:");
scanf("%d",&n);
fibo(n);
}
int fibo(int n)
{
int i=0,j=1,k=2,r,f;
printf("%d %d ", i,j);
while(k{
f=i+j;
i=j;
j=f;
printf(" %d",j);
k++;
}
}
main()
{
int n;
printf("Enter the number range:");
scanf("%d",&n);
fibo(n);
}
int fibo(int n)
{
int i=0,j=1,k=2,r,f;
printf("%d %d ", i,j);
while(k
f=i+j;
i=j;
j=f;
printf(" %d",j);
k++;
}
}
No comments
Post a Comment