Friday, July 11, 2014

Fibonacci Series

#include<iostream.h>
#include<conio.h>
void main()
{
  int a=0,b=1,c=0,n;
  clrscr();
  cout<<"Enter the limit:";
  cin>>n;
  cout<<a<<"\n"<<b<<;
  while(c<=n)
  {
    c=a+b;
    if(c>n);
      break;
    a=b;
    b=c;
  }
  getch();
}

No comments:

Post a Comment