+ 1
how to print a fibonacci series..
give me a program
1 Answer
+ 2
#include <iostream>
using namespace std;
int main()
{
long a,b,c,i,n;
a=0;
b=1;
cout<<"enter number of terms you want to print"<<endl;
cin>>n;
cout<<a<<" "<<b;
for(i=1;i<=n-2;i++)
{
c=a+b;
cout<<" "<<c;
a=b;
b=c;
}
return 0;
}
hope you got the answer;)