3.7

#include<iostream>
using namespace std;
class fibonnaci
{
    int r;
public:
    void set()
    {
        cout<<"enter the range:";
        cin>>r;
       
    }
    void display()
    {
        int fib1=0,fib2=1;
        int temp=0;
        while(temp<=r)
        {
            cout<<temp<<"\t";
            fib1=fib2;
            fib2=temp;
            temp=fib1+fib2;
        }
    }
};
int main()
{
    fibonnaci ob;
    ob.set();
    ob.display();
    return 0;
}

Total Pageviews