Write a C++ program to generate a Fibonacci Series up to 10 steps. The initial value is 0 and 1.
Hint:
Fibonacci Series in C: In case of fibonacci series, next number is the sum of previous two numbers for example 0, 1, 1, 2, 3, 5, 8, 13, 21 etc. The first two numbers of fibonacci series are 0 and 1.
Example in C: http://www.c-programming-blog.com/p/fibonacci-series-in-c-fibonacci-series.html
Hint:
Fibonacci Series in C: In case of fibonacci series, next number is the sum of previous two numbers for example 0, 1, 1, 2, 3, 5, 8, 13, 21 etc. The first two numbers of fibonacci series are 0 and 1.
Example in C: http://www.c-programming-blog.com/p/fibonacci-series-in-c-fibonacci-series.html
MD.Alamin Hosen
ReplyDeleteID.201910261
Batch.60th
//Write a C++ program to generate a Fibonacci Series 1 to 10 steps. The initial value is 0 and 1.
#include
using namespace std;
class step
{
public:
int t,t1,i,sum=0,n;
step(int a, int b)
{
t=a;
t1=b;
}
void pos()
{
cout<<"Enter the value :"<>n;
cout<<t<<endl;
cout<<t1<<endl;
}
int out()
{
for(i=1; i<=10; i++)
{
sum=t+t1;
t=t1;
t1=sum;
cout<<sum<<endl;
}
}
};
int main()
{
step a(0,1);
a.pos();
a.out();
}
Md Raihan Molla
ReplyDeleteID:201910061 CSE 60th
#include
using namespace std;
class B
{
public:
int t,t1,i,sum=0,n;
B(int a, int b)
{
t=a;
t1=b;
}
void pos()
{
cout<<"enter a value :"<>n;
cout<<t<<"\n";
cout<<t1<<endl;
}
int out()
{
for(i=1;i<=n;i++)
{
sum=t+t1;
t=t1;
t1=sum;
cout<<sum<<endl;
}
}
};
int main()
{
B a(0,1);
a.pos();
a.out();
}
Name: MD Aminul Islam Anik
ReplyDeleteID:201910353, Batch : 60th
#include
using namespace std;
class step
{
public:
int t,t1,i,sum=0,n;
step(int a,int b)
{
t=a;
t1=b;
}
void pos()
{
cout<<"Enter valu:"<>n;
cout<<t<<endl;
cout<<t1<<endl;
}
int out()
{
for(i=1; i<=n; i++)
{
sum=t+t1;
t=t1;
t1=sum;
cout<<sum<<endl;
}
}
};
int main()
{
step a(0,1);
a.pos();
a.out();
}
Md.Ali Zinnah
ReplyDeleteID: 201910567
Batch:60
#include
using namespace std;
class m
{
public:
int a,sum=0,sum1=1,n,next;
int additional()
{
cin>>n;
cout<<0<<endl<<1<<endl;
for(a=1;a<n;a++)
{
next=a;
next=sum+sum1;
sum=sum1;
sum=next;
cout<<next<<endl;
}
}
};
int main()
{
m obj;
obj.additional();
}
Md:Towhidul Islam Tuhin
ReplyDeleteBatch-57,sec-C
ID-201811105
//WAP to print the first 10 steps of fuburicy series
#include
using namespace std;
class f
{
public:
int n,t,t1,s=0;
f(int a, int b)
{
t=a;
t1=b;
}
void d()
{
cout<<"enter number";
cin>>n;
cout<<t<<endl<<t1<<endl;
}
int a()
{
for(int i=1;i<=n;i++)
{
s=t+t1;
t=t1;
t1=s;
cout<<s<<endl;
}
}
};
int main()
{
f obj (0,1);
obj.d();
obj.a();
}
//WAP to print the first 10 steps of fuburicy serice
ReplyDeleteRobin Ahmed.
Batch 60.
#include
using namespace std;
class f
{
public:
int n,t,t1,s=0;
f(int a, int b)
{
t=a;
t1=b;
}
void d()
{
cout<<"enter number";
cin>>n;
cout<<t<<endl<<t1<<endl;
}
int e(){
for(int i=1;i<=n;i++)
{
s=t+t1;
t=t1;
t1=s;
cout<<s<<endl;
}
}
};
int main()
{
f obj(0,1);
obj.d();
obj.e();
}
//WAP to print the first 10 steps of fuburicy serice
ReplyDeleteRobin Ahmed
ID:201910109
Batch:60
#include
using namespace std;
class f
{
public:
int n,t,t1,s=0;
f(int a, int b)
{
t=a;
t1=b;
}
void d()
{
cout<<"enter number";
cin>>n;
cout<<t<<endl<<t1<<endl;
}
int e(){
for(int i=1;i<=n;i++)
{
s=t+t1;
t=t1;
t1=s;
cout<<s<<endl;
}
}
};
int main()
{
f obj(0,1);
obj.d();
obj.e();
}
md Rabiul auwal
ReplyDeleteid 201911082
batch 60th
#include
using namespace std;
class step
{
public:
int t,t1,i,sum=0,n;
step(int a, int b)
{
t=a;
t1=b;
}
void pos()
{
cout<<"Enter the value :"<>n;
cout<<t<<endl;
cout<<t1<<endl;
}
int out()
{
for(i=1; i<=10; i++)
{
sum=t+t1;
t=t1;
t1=sum;
cout<<sum<<endl;
}
}
};
int main()
{
step a(0,1);
a.pos();
a.out();
}
name:kawsar ashmed
ReplyDeleteid:201910560
batch:60
#include
using namespace std;
class k
{
public:
int a,sum=0,sum1=1,n,next;
int additional()
{
cin>>n;
cout<<0<<endl<<1<<endl;
for(a=1;a<=n;a++)
{
next=a;
next=sum+sum1;
sum=sum1;
sum1=next;
cout<<next<<endl;
}
}
};
int main()
{
k obj;
obj.additional();
}
//WAP to print the first 10 steps of fuburicy serice
ReplyDelete#include
using namespace std;
class f
{
public:
int n,m,m1,s=0;
f(int a, int b)
{
m=a;
m1=b;
}
void d()
{
cout<<"enter number";
cin>>n;
cout<<m<<endl<<m1<<endl;
}
int e(){
for(int i=1;i<=n;i++)
{
s=m+m1;
m=m1;
m1=s;
cout<<s<<endl;
}
}
};
int main()
{
f obj(0,1);
obj.d();
obj.e();
}
Eva Akter
ReplyDeleteID:201910109
#include
using namespace std;
class e
{
public:
int n,t,t1,s=0;
e(int a, int b)
{
t=a;
t1=b;
}
void l()
{
cin>>n;
cout<<t<<endl<<t1<<endl;
}
int k(){
for(int i=1;i<=n;i++)
{
s=t+t1;
t=t1;
t1=s;
cout<<s<<endl;
}
}
};
int main()
{
e obj(0,1);
obj.l();
obj.k();
}
// MD.RAFSAN HABIB
ReplyDelete// ID. 201730597
//Write a C++ program to generate a Fibonacci Series 1 to 10 steps. The initial value is 0 and 1.
#include
using namespace std;
class step
{
public:
int t,t1,i,sum=0,n;
step(int a, int b)
{
t=a;
t1=b;
}
void pos()
{
cout<<"Enter the value :"<>n;
cout<<t<<endl;
cout<<t1<<endl;
}
int out()
{
for(i=1; i<=10; i++)
{
sum=t+t1;
t=t1;
t1=sum;
cout<<sum<<endl;
}
}
};
int main()
{
step a(0,1);
a.pos();
a.out();
}
MD.Abdul karim
ReplyDeleteID.201910508
Batch.60th
//Write a C++ program to generate a Fibonacci Series 1 to 10 steps. The initial value is 0 and 1.
#include
using namespace std;
class step
{
public:
int t,t1,i,sum=0,n;
step(int a, int b)
{
t=a;
t1=b;
}
void pos()
{
cout<<"Enter the value :"<>n;
cout<<t<<endl;
cout<<t1<<endl;
}
int out()
{
for(i=1; i<=10; i++)
{
sum=t+t1;
t=t1;
t1=sum;
cout<<sum<<endl;
}
}
};
int main()
{
step a(0,1);
a.pos();
a.out();
}
Jhumur Aktar
ReplyDeleteID.201910687
60th
//WAP to print the first 10 steps of fuburicy serice
//Write a C++ program to generate a Fibonacci Series 1 to 10 steps. The initial value is 0 and 1.
#include
using namespace std;
class step
{
public:
int t,t1,i,sum=0,n;
step(int a, int b)
{
t=a;
t1=b;
}
void pos()
{
cout<<"Enter the value :"<>n;
cout<<t<<endl;
cout<<t1<<endl;
}
int out()
{
for(i=1; i<=10; i++)
{
sum=t+t1;
t=t1;
t1=sum;
cout<<sum<<endl;
}
}
};
int main()
{
step a(0,1);
a.pos();
a.out();
}
sharmin Akter
ReplyDeleteID.201910106
Batch.60th
//Write a C++ program to generate a Fibonacci Series 1 to 10 steps. The initial value is 0 and 1.
#include
using namespace std;
class step
{
public:
int t,t1,i,sum=0,n;
step(int a, int b)
{
t=a;
t1=b;
}
void pos()
{
cout<<"Enter the value :"<>n;
cout<<t<<endl;
cout<<t1<<endl;
}
int out()
{
for(i=1; i<=10; i++)
{
sum=t+t1;
t=t1;
t1=sum;
cout<<sum<<endl;
}
}
};
int main()
{
step a(0,1);
a.pos();
a.out();
}