Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Program for factorial of a number using recursive function in C

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 566
    Comment on it

    What is Factorial ?

    Factorial of a no. means multiplying below numbers. Factorial is denoted by ! Exclamation mark
    Eg:- 5! means :- 5 * 4 * 3 * 2 * 1 = 120

    What is a Recursive function?

    Definition:- A function which calls itself is called as Recursive function & technique is called as Recursion

    Program for factorial of a number using recursive function in C

    #include<stdio.h>
    #include<conio.h>
    int fn(int n);
    void main()
    {
        int num, f;
       clrscr();
       // Enter the number for factorial 
       printf(\n Enter the number:-);
       scanf(%d, num);
       f=fn(num);
       printf(\n The Factorial number:-%d,f);
       getch();
    }
       int fn(int n)
       { 
           int y;
           if ((n==0)||(n==1))
               y=1;
          else
                y=n*fn(n-1);
                return(y);
      }
    

    Output:-

    Enter the number:- 5
    The Factorial number:- 120
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: