Tuesday, February 10, 2015

C 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<<"How many numbers?";
cin>>n;
cout<<"Fabonacci series
"<<first<<" "<<second;

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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.