stack operation for recurssive factorial function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manjiri
    New Member
    • Nov 2006
    • 40

    #1

    stack operation for recurssive factorial function

    Hello everybody...


    I want to know stack operation for recurssive factorilal function..... Means how it exactly returns value and over all calcultion will be carried out...

    Plz let me know...

    Thank you,
    Manjiri
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    It depends on your factorial function. If you post the code you are trying to analyze, we can try to explain what's happening.

    Comment

    • hirak1984
      Contributor
      • Jan 2007
      • 316

      #3
      first make your question clear,preferabl y with a sample code.

      Comment

      • Manjiri
        New Member
        • Nov 2006
        • 40

        #4
        Originally posted by Ganon11
        It depends on your factorial function. If you post the code you are trying to analyze, we can try to explain what's happening.


        well friends I am talking about any function which calculates the factorail of given number recursively...

        Any way here is my code... Plz see and exlpain....

        Code:
        #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);
        }

        Comment

        Working...