I want to know stack operation for recurssive factorilal function..... Means how it exactly returns value and over all calcultion will be carried out...U can follow the below code and explain...
Expand|Select|Wrap|Line Numbers
- #include<stdio.h>
- int fact(int);
- int main()
- {
- int f,n;
- printf("Enter the number whose factorial you want to find..\n");
- scanf("%d",&n);
- f=fact(n);
- printf("Factorial of given number is %d\n",f);
- return 0;
- }
- int fact(int n)
- {
- int f;
- if(n==0)
- return(1);
- else
- return(fact(n-1)*n);
- }
Thank you,
Manjiri