C program to to display Fibinacci Series and its sum using for loop

 C program to to display Fibinacci Series and its sum using for loop


 /************************************************************

 C program to to display Fibinacci Series and its sum using for loop

 ***********************************************************/

 

 #include<stdio.h>

 #include<conio.h>

 void main()

 {

     int i,num, sum=0,f0=0,f1=1,f2;

     //clrscr();

     printf("** OUTPUT**\n");

     printf("How many terms of Fibonacci series you want\n");

     scanf("%d",&num);

     printf("The Fibonacci series of %d is \n%d\n%d\n",num, f0,f1);

     for(i=1;i<=num;i++)

     {

         f2=f0+f1;

         printf("%d\n",f2);

         f0=f1;

         f1=f2;

         sum=sum+f2;

       

        

     }

     printf("The sum of fibonacci terms is %d\n",sum);

     printf("End of program");

 }

** OUTPUT**

How many terms of Fibonacci series you want

10

The Fibonacci series of 10 is 

0

1

1

2

3

5

8

13

21

34

55

89

The sum of fibonacci terms is 231

End of program


टिप्पणी पोस्ट करा

0 टिप्पण्या