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
What is difference between union and structure in c?
What does sizeof int return?
Does free set pointer to null?
application attempts to perform an operation?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
difference between object file and executable file
Explain how are portions of a program disabled in demo versions?
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }
Explain function?
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
Should I learn data structures in c or python?
What does s c mean on snapchat?
Which is best book for data structures in c?
What is void main ()?
What is the use of getchar functions?