Program -
#include<iostream.h>
#include<conio.h>
class a
{
protected:
int a;
public:
a()
{
a=0;
}
};
class b
{
protected:
int b;
public:
b()
{
b=1;
}
};
class c:public
a,public b
{
int c,a,b;
public:
c():a(),b()
{
c=a+b;
}
void print()
{
cout<<c<<"";
a=b;b=c;c=a+b;
}
};
void main()
{
clrscr();
int n;
cout<<"enter
number of terms==>";
cin>>n;
c c;
cout<<"the
series is==>0 1";
for(int
i=1;i<=n-2;i++)
c.print();
getch();
}
Output -
Enter number of
terms== >9
The series is == > 0 1 1 2 3 5 8 13 21
0 comments:
Post a Comment