C program to find the Sum of Fibonacci Series

Write a C program to find the sum of Fibonacci series numbers using a while loop. In this c example, the whole loop iterate numbers from 0 to n to print Fibonacci numbers and find the sum of those Fibonacci series numbers.

#include<stdio.h>
 
int main()
{
   int Number, First = 0, Second = 1, Next = 0, sum = 0;
 
   printf("Enter Maximum Number for Fibonacci Series = ");
   scanf("%d", &Number);
 
   printf("First %d Fibonacci Series Numbers:\n", Number);
 
   while( First <= Number)
   {
      printf("%d ", First);
      sum = sum + First;
      Next = First + Second;
      First = Second;
      Second = Next; 
   }
   printf("\nThe Sum of Fibonacci Series Numbers = %d\n", sum);
}
C program to find the Sum of Fibonacci Series

C program to find the Sum of Fibonacci Series using the for loop

#include <stdio.h>
int main()
{
	int Number, Next, Second = 1, sum = 0;

	printf("\n Please Enter the Range Number: ");
	scanf("%d",&Number);
	
	for(int First = 0; First <= Number;) 
	{
		printf("%d ", First);
      	        sum = sum + First;
      	        Next = First + Second;
		First = Second;
      	        Second = Next; 
	}
	printf("\nThe Sum of Fibonacci Series Numbers = %d\n", sum);
}
 Please Enter the Range Number: 25
0 1 1 2 3 5 8 13 21 
The Sum of Fibonacci Series Numbers = 54

In this c example, the fibonacciSeries recursive function calculates the sum of Fibonacci series numbers by calling it recursively.

#include<stdio.h>

int fibonacciSeries(int Number)
{
   if ( Number == 0 )
      return 0;
   else if ( Number == 1 )
      return 1;
   else
      return ( fibonacciSeries(Number - 1) + fibonacciSeries(Number - 2) );
} 
 
int main()
{
   int Number, i = 0, j, sum = 0;
 
   printf("\nEnter Maximum Number for Fibonacci Series = ");
   scanf("%d", &Number);
 
   printf("Fibonacci Series Numbers up to %d:\n", Number);
 
   for ( j = 0 ; j < Number; j++ )
   {
      printf("%d   ", fibonacciSeries(j));
      sum = sum + fibonacciSeries(j);
   }
     printf("\nThe Sum of Fibonacci Series Numbers = %d\n", sum);
}
Enter Maximum Number for Fibonacci Series = 20
Fibonacci Series Numbers up to 20:
0   1   1   2   3   5   8   13   21   34   55   89   144   233   377   610   987   1597   2584   4181   
The Sum of Fibonacci Series Numbers = 10945