Write a program to find sum of Fibonacci series using function

 Code:-

#include<stdio.h>
int fib(int n)
{
if(n==1||n==2)
return 1;
return (fib(n1)+fib(n2));
}
int main()
{
int n,i,sum=0;
printf(“Enter number of term in fibbo seriesn”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
sum=sum+fib(i);
}
printf(“Sum of the series is: %d”,sum);
return 0;
}

Output:-

Enter number of term in fibbo series
5
Sum of the sereis is: 12

Recommended Post:-

         MCQs:-


Leave a Reply

Your email address will not be published.