logo codesdope

write program to find out fectorial any number according to user choice and data take from keyword

   MD IMTIYAZ , Maharshi Dayanand university haryana


Answers

  •    Aakhya Singh

    The following code prints the factorial of a number. You can find the explanation of the code in the Recursion section of https://www.codesdope.com/c-my-functions/.

    #include <stdio.h>
    
    int factorial( int a ) /* function */
    {
        if( a == 0 || a == 1)
        {
            return 1;
        }
        else
        {
            return a*factorial(a-1);
        }
    }
    
    int main()
    {
        int n;
    
        printf("Enter number\n");
        scanf("%d", &n);
    
        int fact = factorial(n);
    
        printf("Factorial of %d is %d\n", n, fact);
        return 0;
    }
    

     


    • thanks
      - MD IMTIYAZ

Write your answer
Close

Welcome.please sign up.

Close

Welcome.please login.