64 630
Assignments Done
99,1%
Successfully Done
In September 2018

Answer to Question #5193 in C++ for aswinrdev

Question #5193
A PROGRAM TO GENERATE FIBANOCCI UPTO A GIVEN NO 112358
Expert's answer
#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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions