Ads 468x60px

Tuesday 15 January 2013

Fibonacci Series C++ Program

This code will ask the user to enter the length of  the series that he want to generate, once the user will give the length then the program will generate the Fibonacci series.
#include<iostream.h>
#include<conio.h>

void main()
{
 clrscr();
 int a=0,b=1,c,r,i;
 cout<<"Enter the length:\t";
 cin>>r;
 cout<<a<<"\t"<<b<<"\t";
 for(i=0;i<r;i++)
 {
  c=a+b;
  cout<<c<<"\t";
  a=b;
  b=c;
 }
 getch();
}

Share if you liked this Post using your favorite sharing service:

Subscribe Updates, Its FREE!

 
Related Posts Plugin for WordPress, Blogger...