/*
program to generate Fibonacci series in C++.
*/
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
unsigned long first,second,third,n;
first=0; second=1;
cout<<"How many elements(>5)?\n";
cin>>n;
cout<<"Fibonacci series\n";
cout<<first<<" "<<second;
for(int i=2;i<n;++i)
{
third=first+second;
cout<<" "<<third;
first=second;
second=third;
}
getch();
return(0);
}
0 comments:
Post a Comment