ADS

C++ Program To Find Factorial Of Two Numbers Using Recursion Function | C++ Programming

C++ Program To Find Factorial Of Two Numbers Using Recursion Function

#include<iostream>
using namespace std;
long int fact(int);
int main()
{
 int n1,n2;
 cout<<"Enter number"< cin>>n1>>n2;
 cout<<n1<<"! = "<<fact(n1)<<endl;
 cout<<n2<<"! = "<<fact(n2)<<endl;
}
long int fact(int n)
{
 if(n<=1)
 return 1;
 else
  return (n*fact(n-1));
}

OUTPUT


Enter number
5
4
5! = 120
4! = 24

Post a Comment

0 Comments