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
Explain what is the difference between the expression '++a' and 'a++'?
What is the purpose of void pointer?
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
What are the header files used in c language?
Which programming language is best for getting job 2020?
What is conio h in c?
What is the use of f in c?
Is exit(status) truly equivalent to returning the same status from main?
What is realloc in c?
Why pointers are used?
What is unsigned int in c?
What are the similarities between c and c++?
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
What's the total generic pointer type?
hi, which software companys will take,if d candidate's % is jst 55%?