Program -
#include<iostream.h>
#include<conio.h>
class fibbo
{
Private:
unsigned long int
i,j,k;
public:
fibbo()
{
i=0;j=1;k=i+j;
display();
{
cout<<i<<j;
}}
display()
{
cout<<"\n"<<k;
return(k);
}
void operator++()
{
i=j;j=k;k=i+j;
}
~fibbo()
{
cout<<"distroctor
invoked";
}};
void main()
{
fibbo m;
int n,i;
cout<<"\n
enter the value of n:";
cin>>n;
m.display();
for(i=1;i<n;i++)
{
m.display();
++m;
}
getch();
}
Output -
enter the value of n:9
1
1
2
3
5
8
13
21
34
0 comments:
Post a Comment