#include<iostream.h>
#include<conio.h>
class fibo
{
int n,a,b,c;
public:
fibo()
{
cout<<"Enter the numbers of terms ";
cin>>n;
a=1;
b=1;
}
void proceed()
{
for(int i=1;i<=n;i++)
{
c=a+b;
a=b;
b=c;
}
}
~fibo()
{
cout<<"The Result for the series is: "<<c;
}
};
void main()
{
clrscr();
fibo f;
f.proceed();
getch();
}
#include<conio.h>
class fibo
{
int n,a,b,c;
public:
fibo()
{
cout<<"Enter the numbers of terms ";
cin>>n;
a=1;
b=1;
}
void proceed()
{
for(int i=1;i<=n;i++)
{
c=a+b;
a=b;
b=c;
}
}
~fibo()
{
cout<<"The Result for the series is: "<<c;
}
};
void main()
{
clrscr();
fibo f;
f.proceed();
getch();
}
No comments:
Post a Comment