Answer to Question #3310 in C++ for mukunda
Write a program to calculate the factorial of given number.
1
2011-07-06T05:39:00-0400
#include <iostream>
using namespace std;
double calculate_factorial (double number)
{
if (number == 0) return 1.0;
return number * calculate_factorial(number-1);
}
int main()
{
double number = 8;
double factorial = calculate_factorial (number);
cout << "The factorial is " << factorial << endl;
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment