Write the program for fibonacci in c++?

Answer Posted / darren chang

int fib(int input)
{
if(input==0)
return 0;
if((input==1)||(input==2))
return 1;
else
return fib(input-1)+fib(input-2);
}

Is This Answer Correct ?    10 Yes 31 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is not a valid keyword a) public b) protected c) guarded

1019


What is endl?

917


How is modularity introduced in C++?

974


Is c# written in c++?

742


Why do we need constructors in c++?

872


What does count ++ do in c++?

959


What is abstraction in c++ with example?

809


What are the benefits of pointers?

810


What does n mean in c++?

860


What is this pointer in c++?

1057


What is flush programming?

789


What language is a dll written in?

753


Where is atoi defined?

807


How does java differ from c and c++?

739


Which programming language is best to learn first?

812