PROGRAM FOR DEFINING A CLASS FIBONACCI USING CONSTRUCTOR.
#include<iostream.h>
#include<conio.h>
class
FIBONACCI
{
public:
int a,b,n,i,c;
FIBONACCI();
FIBONACCI(int,int,int);
void get_FIBONACCI()
{
cout<<x;
cout<<y;
for(i=1;i<=(z-2);i++)
{
c=x+y;
cout<<c;
x=y;
y=z;
}
}
};
FIBONACCI::FIBONACCI()
{
a=0;
b=1;
n=10;
}
FIBONACCI::FIBONACCI()
{
x=a;
y=b;
z=n;
}
void main()
{
FIBONACCI ob;
ob.FIBONACCI(1,2,10);
ob.get_FIBONACCI();
getch();
}
Comments
Post a Comment