Our Blog Contain Detail about Some Technical Aspect like Programming, Blogger, Tools and Tip, Suggestion, Motivational, Health, Program in C and Java, Html

Write a program to find sum of Fibonacci series using function.

 Write a program to find sum of Fibonacci series using function.



#include<conio.h>
#include<stdio.h>
int sumfab(int num)
{
     int a=1,b=1,sum=2,i,c;
     printf("%d,%d,",a,b);
     for(i=3;i<=num;i++)
     {
          c=a+b;
          sum=sum+c;
          a=b;
          b=c;
          printf("%d,",c);
     }
     return sum;
}

void main()
{

     int n,sum;
     printf("enter a number \n");
     scanf("%d",&n);
     sum=sumfab(n);
     printf("the sum is %d",sum);
     getch();
}

Share:

No comments:

Post a Comment

Translate

Followers

Email Subscription

Enter your email address:

Delivered by FeedBurner

Recent Posts

Theme Support

Need our help to upload or customize this blogger template? Contact me with details about the theme customization you need.