NBA - Boston Celtics

Monday, 22 October 2012

Fibonacci series using Fuction


#include<iostream.h>
int fib(int n);
int i,first=0,second=1,third,n;
void main()
{
cout<<"enter the value of n to find fibonacci series : ";
cin>>n;
cout<<first<<","<<second;
int result;
result=fib(n);
}
int fib(int n)
{
for(i=1;i<=n;i++)
{
third=first+second;
cout<<","<<third;
first=second;
second=third;
}
}


No comments:

Post a Comment