#include<iostream>
using namespace std;
int f1=-1,f2=1,f3;
class fib
{
public:
void calculate()
{
f3=f1+f2;
cout<<f3<<endl;
f1=f2;
f2=f3;
}
};
int main()
{
int n;
fib obj;
cout<<"Enter the value of n:";
cin>>n;
for(int i=0;i<n;i++)
{
obj.calculate ();
}
return 0;
}
OUTPUT:
BY
REGU RAM SV.
Post a Comment