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
What is virtual destructor ans explain its use?
Explain linked list using c++ with an example?
What are exceptions c++?
Reverse the Linked List. Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL
Which programming language is best?
How do I run a program in notepad ++?
How a pointer differs from a reference?
What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
which operator is used for performing an exponential operation a) > b) ^ c) none
What is the difference between reference and pointer?
How delete [] is different from delete?
What is :: operator in c++?
What is c++ prototype?
Can we specify variable field width in a scanf() format string? If possible how?
What is the best way to declare and define global variables?