Fibonacci series: – A number in the series which is calculating by adding previous two number.

Ex: – 0, 1, 1, 2, 3, 5, 7, 13, 21, 34 _ _ _ _ _

#include<iostream.h>
#include<conio.h>
void main()
{
                int series,x=0,y=1,z,i;
                clrscr();
                cout<<"Enter The Fibonacci Series :- ";
                cin>>series;
                cout<<x<<"\t"<<y;
                for(i=1;i<series;i++)
                                {
                                z=x+y;
                                cout<<"\t"<<z;
                                x=y;
                                y=z;
                                }
                getch();
}

42

Advertisements