Search This Blog

Sunday, 23 August 2020

fabonacci series

 #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

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts