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 data structure in c++?
What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor
How do you generate a random number in c++?
Can we specify variable field width in a scanf() format string? If possible how?
What is a dll entry point?
What does the nocreate and noreplace flag ensure when they are used for opening a file?
Are c and c++ similar?
Can the creation of operator** is allowed to perform the to-the-power-of operations?
Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.
What is the use of 'this' pointer?
Explain object slicing in c++?
What is the first name of c++?
What do you mean by late binding?
What does flush do?
What is const pointer and const reference?