stack of a c program

Posted by ckarthickit on Stack Overflow See other posts from Stack Overflow or by ckarthickit
Published on 2010-06-10T16:59:46Z Indexed on 2010/06/10 17:13 UTC
Read the original article Hit count: 196

Filed under:
|

how the stack would look like for the following program if I give input as 5.

#include <stdio.h>

int fibonacci(int number)
{
  int retval;
  if (0 == number){
    return 0;
  }
  if (1 == number){
    return 1;
  }
  return(fibonacci(number-1) + fibonacci(number-2));
}

int main()
{
  int number = 0;
  int fibvalue = 1;
  while (1){
    printf("please enter the number\n");
    scanf("%d", &number);
    fibvalue = fibonacci(number);
    printf("computed fibonacci value %d\n", fibvalue);
  }
  return 1;
}

also give me links where i can learn about it

© Stack Overflow or respective owner

Related posts about c

    Related posts about homework