C program to to display Fibinacci Series using for loop

 

C program to to display Fibinacci Series using for loop


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

 C program to to display Fibinacci Seriesl using for loop

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

 

 #include<stdio.h>

 #include<conio.h>

 void main()

 {

     int i,num, 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;

       

        

     }

     printf("End of program");

 }


** OUTPUT**

How many terms of Fibonacci series you want

8

The Fibonacci series of 8 is 

0

1

1

2

3

5

8

13

21

34

End of program



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

0 टिप्पण्या