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);
}
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / vignesh1988i
here the return function will give an error message or it
will only take the first function (ie) fibbo(n-1) since
after return this is the first recursive function
called.... so this altast return 1 to the main program....
that's all.... as for as i know this will be the
procedure...... and then the "or" must not be used .. only
logicalOR must be used ||.........
Is This Answer Correct ? | 0 Yes | 1 No |
any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above
Is a pointer a kind of array?
write the program for maximum of the following numbers? 122,198,290,71,143,325,98
program to find a smallest number in an array
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }
write a program of bubble sort using pointer?
What is the size of structure pointer in c?
Why we write conio h in c?
Where static variables are stored in memory in c?
Why structure is used in c?
What is wrong with this program statement? void = 10;
#ifdef TRUE int I=0; #endif main() { int j=0; printf("%d %d\n",i,j); }