Social Icons

Saturday, 15 February 2014

Program to print Fibonacci series

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
unsigned long n,first,second,third;
first=0;
second=1;
cout<<"\n How many elements : ";
cin>>n;
cout<<"\n Fabonacci series is  \n"<<first<<" "<<second;

for(int i=2;i<n;++i)
{
third=first+second;
cout<<" "<<third;
first=second;
second=third;
}
getch();
}

                                               Output

No comments:

Post a Comment