C++ program to generate Fibonacci series
Program
#include<iostream.h>
using namespace std;
int main()
{
int a=0,b=1,i,n,c;
cout<<"enter the limit";
cin>>n;
cout<<endl<<a<<b;
for(i=2;i<=n;i++)
{
c=a+b;
cout<<c;
a=b;
b=c;
}
return 0;
}
using namespace std;
int main()
{
int a=0,b=1,i,n,c;
cout<<"enter the limit";
cin>>n;
cout<<endl<<a<<b;
for(i=2;i<=n;i++)
{
c=a+b;
cout<<c;
a=b;
b=c;
}
return 0;
}
Comments
Post a Comment