#include<iostream>
using namespace std;
int main()
{
int n,a=1,b=2,next,c;
cout<<"enter the no of terms\n";
cin>>n;
cout<<"first "<<n<<" terms of fibonacci series are:-\n";
for(c=0;c<n;c++)
{
if(c<=1)
next = c;
else
{
next=a+b;
a=b;
b=next;
}
cout<<next<<"\n";
}
return 0;
}
No comments:
Post a Comment