Answer to Question #3310 in C++ for mukunda

Question #3310
Write a program to calculate the factorial of given number.
1
Expert's answer
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS