Write a program to print the factorial of a number using the method void prnFactorial(int n).
Answers
Answered by
1
Answer:
// C++ program to find factorial of given number
#include <iostream>
using namespace std;
// function to find factorial of given number
unsigned int factorial(unsigned int n)
{
if (n == 0)
return 1;
return n * factorial(n - 1);
}
// Driver code
int main()
{
int num = 5;
cout << "Factorial of "
<< num << " is " << factorial(num) << endl;
return 0;
}
Similar questions