Factorial of a Number In C Using Recursion

In this article, we are going to write a program to find Factorial of a Number In C Using Recursion.

To make this program, we will use the following concept given below.

If you do not know about these topics well, then you may not understand this program, so you should know about them in detail from the link given above.

Now without wasting time let’s start programming.

Factorial of a Number In C Using Recursion

Page Contents

Factorial of a Number In C Using Recursion

Algorithm

  • Program Start
  • Declaring Variable
  • Input Number From the user
  • Calling Recursive Function
  • Display Result Through Printf Function
  • Program End

Program

//Factorial of a Number In C Using Recursion

#include<stdio.h>
int fact(int );
void main()
{ //variable declaration
  int x,z;
  
  //input number
  printf("Enter a number : ");
  scanf("%d",&x);
  
  z=fact(x); //calling recursive function to find factorial
  printf("factorial is %d",z);
}
int fact(int n)
{   int ft=1;
    if(n==1)
    return(n);
    ft=n*fact(n-1);
    return(ft);
}

Output

Enter a number : 5
factorial is 120

Conclusion

So friends, in this article, we have written a program to find Factorial of a Number In C Using Recursion.

If you have difficulty to understand any program or have any doubts or questions, then tell me in the comment below.

Jeetu Sahu is A Web Developer | Computer Engineer | Passionate about Coding, Competitive Programming, and Blogging

Leave a Comment

Ads Blocker Image Powered by Code Help Pro
Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Refresh
Powered By
CHP Adblock Detector Plugin | Codehelppro