i want explaination about the program and its stack reprasetaion
fibbo(int n)
{
if(n==1 or n==0)
return n;
else
return fibbo(n-1)+fibbo(n-2);
}
main()
{
fibbo(6);
}
Answer Posted / abdur rab
#include <stdio.h>
int fibonacci ( int nNumber )
{
if ( ( nNumber == 0 ) || ( nNumber == 1 ) ) return
( nNumber );
return fibonacci ( nNumber -1 ) + fibonacci (
nNumber - 2 ) ;
}
int main ( int argc, char* argv[] )
{
printf ( "\n The Fibnoci value :%d", fibonacci (
5 ) );
return ( 1 );
Other than the logical or, everyting is perfect, the
function will recursivel bubble down and for this value it
ud become like this if u copy this to a notepad, with
formating, it ud be easy to understand
4 +
3
3 + 2
2 + 1
2 + 1 1 + 0
1 + 0 ( will return 1 )
1 + 0 ( all others will return 1 )
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
write a program for the normal snake games find in most of the mobiles.
Tell me what is null pointer in c?
Why can’t we compare structures?
What is class and object in c?
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.
What are disadvantages of C language.
Do you know the difference between exit() and _exit() function in c?
Does c have an equivalent to pascals with statement?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
Explain a pre-processor and its advantages.
What is the use of define in c?
How can a string be converted to a number?
Explain how do you determine whether to use a stream function or a low-level function?
Can true be a variable name in c?
List some applications of c programming language?