Comments

Wednesday, October 17, 2012

Generate fabacconi series using function

Posted by at 8:34 AM Read our previous post


Object
       Generate fabacconi  series using function.
      

Source code
#include <iostream>
using namespace std;



int number(int,int);

int number(int x,int y)
{
       int limit=10,sum;
       for(int count=1;count<limit;count++)
       {
       sum=x+y;
       cout<<sum<<",";
       x=y;
       y=sum;
      
       }

       return(sum);
}
void main(void )
{int x,y,answer,limit;
cout<<"Enter a 1st number"<<endl;
cin>>x;
cout<<"Enter second number"<<endl;
cin>>y;


answer=number(x,y);
       cout<<answer;

}

Output
 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Popular Posts

Labels

© Codepirate is powered by Blogger - Template designed by Stramaxon - Best SEO Template