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


Please Help Members By Posting Answers For Below Questions

Why do we use c for the speed of light?

603


What is a void * in c?

591


In C language what is a 'dangling pointer'?

632


Is array a primitive data type in c?

573


What is 'bus error'?

641






Explain what is the benefit of using an enum rather than a #define constant?

715


is it possible to create your own header files?

631


Why can arithmetic operations not be performed on void pointers?

586


Do you know what are bitwise shift operators in c programming?

581


How reliable are floating-point comparisons?

622


How can I swap two values without using a temporary?

612


how we can make 3d venturing graphics on outer interface

3998


What does %c mean in c?

644


Write a program for finding factorial of a number.

629


Explain the use of bit fieild.

708