Program to find the sum of fibonacci series
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int a = -1, b = 1, c = 0, i, n, sum = 0;
clrscr();
printf("Enter the limit : ");
scanf("%d", &n);
printf("\nThe fibonacci series is : \n\n");
for(i = 1 ; i <= n ; i++)
{
c = a + b ;
printf("%d \t", c);
sum = sum + c;
a = b;
b = c;
}
printf("\n\nThe sum of the fibonacci series is : %d", sum);
getch();
}
Output:
Enter the limit : 5
The fibonacci series is :
0 1 1 2 3
The sum of the fibonacci series is : 7
-
UpdatedDec 30, 2019
-
Views13,235
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order