Answer to Question #5193 in C++ for aswinrdev
A PROGRAM TO GENERATE FIBANOCCI UPTO A GIVEN NO 112358
1
2011-11-18T09:04:11-0500
#include <iostream.h>
int fib(int n)
{
if((1 == n) || (2 == n)) return 1;
else return fib(n-1) + fib(n-2);
}
int main(){
int i, n;
cout<<"enter n:";
cin>>n;
for(i=1; i<=n; i++) cout << fib(i) << endl;
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment