C++ program to generate Fibonacci Series
Hello today I will tell you how make a C++ program which
will generate Fibonacci series up to number you want to generate. First I will tell you what is Fibonacci series, it
is series which basically starts with 1 0 and 1 and then rest of the number are
obtained by adding the two previous numbers. For example:-
Soo I hope you are now clear with Fibonacci series now the
coding to generate Fibonacci series is:-
______________________________________________________
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr() ;
int a,sum=0,x;
cout<<"\t\t\t\tFIBONACCI SERIES\t\t\t\t";
cout<<"\n\nEnter the number till where you want to generate
Fibonacci series:";
cin>>x;
int f=0,s=1,n;
cout<<"\nThe Fibonacci series will
be:"<<f<<endl;
cout<<"The Fibonacci series will
be:"<<s<<endl;
for(a=1;a<=x;a++)
{
sum=f+s;
f=s;
s=sum;
cout<<"The Fibonacci series
will be:"<<sum<<endl;
}
getch();
}
______________________________________________________________________________
You can download the programm by clicking on download icon↴
Now
as usual if you want to do more formatting then you can perform According to
yourself.
When you will run this program on
C++ then the output will be like this
So enjoy using it and if you want
more program then comment below!!
Thank you!!!!
Comments
Post a Comment