GupShup Study
 
  
A Fibonacci sequence is defined as follows: the first and second terms in the sequence are 0 and 1.Subsequent terms are found by adding the preceding two terms in the sequence. Write a C++ program to generate the first n terms of the sequence using classe
Ashish talpade

A Fibonacci sequence is defined as follows: the first and second terms in the sequence are 0 and 1.Subsequent terms are found by adding the preceding two terms in the sequence. Write a C++ program to generate the first n terms of the sequence using classe

24-Jun-2016 | Ashish talpade |
Program ,

#include<iostream.h>
#include<conio.h>

 class fabonic

 {

  int no,twoaway,next,current;

  public:

  void fabonic_series();

 };

 

 

 void fabonic::fabonic_series()

  {

   gotoxy(5,10);

   cout<<"\n\nenter the number = ";

   cin>>no;

   current=0;

   next=1;

   int i;

   for(i=1;i<=no;i++)

    {

    cout<<endl<<current;

    twoaway=next+current;

    current=next;

    next=twoaway;

    }

   }

 

  void main()

   {

    clrscr();

    fabonic f;

    textcolor(15);

    gotoxy(30,5);

    cprintf("Fabonicc Series");

    gotoxy(30,6);

    cprintf("==============");

    gotoxy(60,20);

    cprintf("Created By :-");

    gotoxy(67,26);

    cprintf("Hitesh Kumar");

    f.fabonic_series();

    getch();

   }

Share With Friends :  

No Any Answer Yet!

Total View : 0