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

What is data structure in c++?

856


What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor

913


How do you generate a random number in c++?

830


Can we specify variable field width in a scanf() format string? If possible how?

904


What is a dll entry point?

738


What does the nocreate and noreplace flag ensure when they are used for opening a file?

888


Are c and c++ similar?

797


Can the creation of operator** is allowed to perform the to-the-power-of operations?

768


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

6145


What is the use of 'this' pointer?

1022


Explain object slicing in c++?

785


What is the first name of c++?

778


What do you mean by late binding?

841


What does flush do?

764


What is const pointer and const reference?

832