Lab Work -1 : Fibonacci

Write a C++ program to generate a Fibonacci Series up to 10 steps. The initial value is 0 and 1.

Hint:

Fibonacci Series in C: In case of fibonacci series, next number is the sum of previous two numbers for example 0, 1, 1, 2, 3, 5, 8, 13, 21 etc. The first two numbers of fibonacci series are 0 and 1.

Example in C: http://www.c-programming-blog.com/p/fibonacci-series-in-c-fibonacci-series.html

15 comments:

  1. MD.Alamin Hosen
    ID.201910261
    Batch.60th
    //Write a C++ program to generate a Fibonacci Series 1 to 10 steps. The initial value is 0 and 1.
    #include
    using namespace std;
    class step
    {
    public:
    int t,t1,i,sum=0,n;
    step(int a, int b)
    {
    t=a;
    t1=b;
    }
    void pos()
    {
    cout<<"Enter the value :"<>n;
    cout<<t<<endl;
    cout<<t1<<endl;

    }
    int out()
    {
    for(i=1; i<=10; i++)
    {
    sum=t+t1;
    t=t1;
    t1=sum;

    cout<<sum<<endl;
    }
    }

    };
    int main()
    {
    step a(0,1);
    a.pos();
    a.out();
    }



    ReplyDelete
  2. Md Raihan Molla
    ID:201910061 CSE 60th


    #include
    using namespace std;
    class B
    {
    public:
    int t,t1,i,sum=0,n;
    B(int a, int b)
    {
    t=a;
    t1=b;
    }
    void pos()
    {
    cout<<"enter a value :"<>n;
    cout<<t<<"\n";
    cout<<t1<<endl;

    }
    int out()
    {
    for(i=1;i<=n;i++)
    {
    sum=t+t1;
    t=t1;
    t1=sum;
    cout<<sum<<endl;
    }
    }

    };
    int main()
    {
    B a(0,1);
    a.pos();
    a.out();
    }

    ReplyDelete
  3. Name: MD Aminul Islam Anik
    ID:201910353, Batch : 60th


    #include
    using namespace std;






    class step
    {
    public:
    int t,t1,i,sum=0,n;
    step(int a,int b)
    {
    t=a;
    t1=b;
    }
    void pos()
    {
    cout<<"Enter valu:"<>n;
    cout<<t<<endl;
    cout<<t1<<endl;

    }
    int out()
    {
    for(i=1; i<=n; i++)
    {
    sum=t+t1;
    t=t1;
    t1=sum;
    cout<<sum<<endl;
    }
    }



    };


    int main()
    {

    step a(0,1);
    a.pos();
    a.out();


    }

    ReplyDelete
  4. Md.Ali Zinnah
    ID: 201910567
    Batch:60

    #include
    using namespace std;
    class m
    {
    public:
    int a,sum=0,sum1=1,n,next;
    int additional()
    {
    cin>>n;
    cout<<0<<endl<<1<<endl;
    for(a=1;a<n;a++)
    {
    next=a;
    next=sum+sum1;
    sum=sum1;
    sum=next;

    cout<<next<<endl;
    }
    }

    };
    int main()

    {
    m obj;
    obj.additional();
    }


    ReplyDelete
  5. Md:Towhidul Islam Tuhin
    Batch-57,sec-C
    ID-201811105
    //WAP to print the first 10 steps of fuburicy series

    #include
    using namespace std;
    class f
    {
    public:

    int n,t,t1,s=0;
    f(int a, int b)
    {
    t=a;
    t1=b;
    }

    void d()
    {
    cout<<"enter number";
    cin>>n;
    cout<<t<<endl<<t1<<endl;
    }
    int a()
    {
    for(int i=1;i<=n;i++)
    {
    s=t+t1;
    t=t1;
    t1=s;
    cout<<s<<endl;
    }
    }





    };
    int main()
    {
    f obj (0,1);
    obj.d();
    obj.a();

    }



    ReplyDelete
  6. //WAP to print the first 10 steps of fuburicy serice
    Robin Ahmed.
    Batch 60.

    #include
    using namespace std;
    class f
    {
    public:

    int n,t,t1,s=0;
    f(int a, int b)
    {
    t=a;
    t1=b;

    }
    void d()
    {
    cout<<"enter number";
    cin>>n;
    cout<<t<<endl<<t1<<endl;
    }
    int e(){

    for(int i=1;i<=n;i++)

    {
    s=t+t1;
    t=t1;
    t1=s;
    cout<<s<<endl;
    }
    }






    };
    int main()
    {
    f obj(0,1);
    obj.d();
    obj.e();

    }

    ReplyDelete
  7. //WAP to print the first 10 steps of fuburicy serice
    Robin Ahmed
    ID:201910109
    Batch:60

    #include
    using namespace std;
    class f
    {
    public:

    int n,t,t1,s=0;
    f(int a, int b)
    {
    t=a;
    t1=b;

    }
    void d()
    {
    cout<<"enter number";
    cin>>n;
    cout<<t<<endl<<t1<<endl;
    }
    int e(){

    for(int i=1;i<=n;i++)

    {
    s=t+t1;
    t=t1;
    t1=s;
    cout<<s<<endl;
    }
    }






    };
    int main()
    {
    f obj(0,1);
    obj.d();
    obj.e();

    }

    ReplyDelete
  8. md Rabiul auwal
    id 201911082
    batch 60th
    #include
    using namespace std;
    class step
    {
    public:
    int t,t1,i,sum=0,n;
    step(int a, int b)
    {
    t=a;
    t1=b;
    }
    void pos()
    {
    cout<<"Enter the value :"<>n;
    cout<<t<<endl;
    cout<<t1<<endl;

    }
    int out()
    {
    for(i=1; i<=10; i++)
    {
    sum=t+t1;
    t=t1;
    t1=sum;

    cout<<sum<<endl;
    }
    }

    };
    int main()
    {
    step a(0,1);
    a.pos();
    a.out();
    }

    ReplyDelete
  9. name:kawsar ashmed
    id:201910560
    batch:60


    #include
    using namespace std;
    class k
    {
    public:

    int a,sum=0,sum1=1,n,next;
    int additional()
    {
    cin>>n;
    cout<<0<<endl<<1<<endl;
    for(a=1;a<=n;a++)
    {
    next=a;
    next=sum+sum1;
    sum=sum1;
    sum1=next;

    cout<<next<<endl;

    }


    }

    };
    int main()
    {
    k obj;
    obj.additional();

    }

    ReplyDelete
  10. //WAP to print the first 10 steps of fuburicy serice

    #include
    using namespace std;
    class f
    {
    public:

    int n,m,m1,s=0;
    f(int a, int b)
    {
    m=a;
    m1=b;

    }
    void d()
    {
    cout<<"enter number";
    cin>>n;
    cout<<m<<endl<<m1<<endl;
    }
    int e(){

    for(int i=1;i<=n;i++)

    {
    s=m+m1;
    m=m1;
    m1=s;
    cout<<s<<endl;
    }
    }






    };
    int main()
    {
    f obj(0,1);
    obj.d();
    obj.e();

    }

    ReplyDelete
  11. Eva Akter
    ID:201910109
    #include
    using namespace std;
    class e
    {
    public:

    int n,t,t1,s=0;
    e(int a, int b)
    {
    t=a;
    t1=b;

    }
    void l()
    {

    cin>>n;
    cout<<t<<endl<<t1<<endl;
    }
    int k(){

    for(int i=1;i<=n;i++)

    {
    s=t+t1;
    t=t1;
    t1=s;
    cout<<s<<endl;
    }
    }






    };
    int main()
    {
    e obj(0,1);
    obj.l();
    obj.k();

    }

    ReplyDelete
  12. // MD.RAFSAN HABIB
    // ID. 201730597

    //Write a C++ program to generate a Fibonacci Series 1 to 10 steps. The initial value is 0 and 1.

    #include
    using namespace std;
    class step
    {
    public:
    int t,t1,i,sum=0,n;
    step(int a, int b)
    {
    t=a;
    t1=b;
    }
    void pos()
    {
    cout<<"Enter the value :"<>n;
    cout<<t<<endl;
    cout<<t1<<endl;

    }
    int out()
    {
    for(i=1; i<=10; i++)
    {
    sum=t+t1;
    t=t1;
    t1=sum;

    cout<<sum<<endl;
    }
    }

    };
    int main()
    {
    step a(0,1);
    a.pos();
    a.out();
    }

    ReplyDelete
  13. MD.Abdul karim
    ID.201910508
    Batch.60th
    //Write a C++ program to generate a Fibonacci Series 1 to 10 steps. The initial value is 0 and 1.
    #include
    using namespace std;
    class step
    {
    public:
    int t,t1,i,sum=0,n;
    step(int a, int b)
    {
    t=a;
    t1=b;
    }
    void pos()
    {
    cout<<"Enter the value :"<>n;
    cout<<t<<endl;
    cout<<t1<<endl;

    }
    int out()
    {
    for(i=1; i<=10; i++)
    {
    sum=t+t1;
    t=t1;
    t1=sum;

    cout<<sum<<endl;
    }
    }

    };
    int main()
    {
    step a(0,1);
    a.pos();
    a.out();
    }

    ReplyDelete
  14. Jhumur Aktar
    ID.201910687
    60th

    //WAP to print the first 10 steps of fuburicy serice
    //Write a C++ program to generate a Fibonacci Series 1 to 10 steps. The initial value is 0 and 1.
    #include
    using namespace std;
    class step
    {
    public:
    int t,t1,i,sum=0,n;
    step(int a, int b)
    {
    t=a;
    t1=b;
    }
    void pos()
    {
    cout<<"Enter the value :"<>n;
    cout<<t<<endl;
    cout<<t1<<endl;

    }
    int out()
    {
    for(i=1; i<=10; i++)
    {
    sum=t+t1;
    t=t1;
    t1=sum;

    cout<<sum<<endl;
    }
    }

    };
    int main()
    {
    step a(0,1);
    a.pos();
    a.out();
    }

    ReplyDelete
  15. sharmin Akter
    ID.201910106
    Batch.60th
    //Write a C++ program to generate a Fibonacci Series 1 to 10 steps. The initial value is 0 and 1.
    #include
    using namespace std;
    class step
    {
    public:
    int t,t1,i,sum=0,n;
    step(int a, int b)
    {
    t=a;
    t1=b;
    }
    void pos()
    {
    cout<<"Enter the value :"<>n;
    cout<<t<<endl;
    cout<<t1<<endl;

    }
    int out()
    {
    for(i=1; i<=10; i++)
    {
    sum=t+t1;
    t=t1;
    t1=sum;

    cout<<sum<<endl;
    }
    }

    };
    int main()
    {
    step a(0,1);
    a.pos();
    a.out();
    }

    ReplyDelete

Comment Here