Jan 31, 2007

C++ Program to generate fibonacci series

A C++ program to generate Fibonacci series or sequence.  While doing engineering many time ask the same question that how to write a program to generate Fibonacci series. Here is how you can achieve it.
Series is 1 1 2 3 5 8 13 21 34 55.............
Here is the code for Fibonacci sequence.

main()

{

clrscr();
int a,b,c;
a=1;
b=1;
c=0;
cout<<a;
cout<<endl<<b;
while (c<50)
{
c=a+b;
cout<<endl<<c;
a=b;
b=c;
}
getch();
}

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us

Blog Archive