Subscribe for more such posts..

Dear Reader...
I hope u are like my posts. If so then please don't forget to like , share and follow my blog for more such posts ,also feel free to write suggestions in the comment box given over here.

Thank you...

Search This Blog

Program to find sum of a fibonacci series up to n terms in C.


#include <stdio.h>
#include <math.h>
int main()
{
   long	double n , first =-1  , second = 1 , sum = 0 , third ;
    int i = 0 ;
  	printf("Enter the range: ");
	scanf("%LF" , &n );
	
	
	for (int i = 0 ; i < n ; i++)
	
	{
		third = first + second ;
		sum = sum + third ;
		first = second ;
		second = third ;
	}
    
   
    
     printf("Sum of Fibonacci series for given range is: %.0Lf\n" , sum);
  
	
	return 0 ;
}

No comments:

Post a Comment