Answer to Question #56579 in C++ for miky

Question #56579
Take an integer from the user and display the factorial of that number
1
Expert's answer
2016-01-19T08:28:40-0500
#include <iostream>

using namespace std;

int main()
{
int value, factorial = 1;
cout << "Input integer = ";
cin >> value;
if (value < 0)
cout << "Invalid input";
else
{
for (int i = 1; i <= value; i++)
{
factorial *= i;
}
cout << "Factorial = " << factorial << "\n";
}
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