Program of Factorial using Recursion in C++
What are recursive functions?
Recursive functions are those functions that repeatedly calls itself directly or indirectly during execution .Steps to write the program
1. Open a turbo c++ compiler or any other compiler.
2. Write the code given below .
#include<iostream.h>
#include<conio.h>
int Factorial(int x) // Factorial Function Coding
{
if(x<=1)
{ return 1; }
else { return x*Factorial(x-1); }
void main() // Main Function Coding
{
clrscr();
int n;
cout<<"\nEnter the value of n";
cin>>n;
cout<<"\nThe factorial of the number "<<n<<"is equal to " <<Factorial(n);
getch();
}
OUTPUT:
it really helped
ReplyDeletethanks for the code
Nice
ReplyDelete