76 309
Assignments Done
Successfully Done
In May 2019

Answer to Question #16053 in C++ for Richard

Question #16053
how do i write a c++ program that will input a number and output its factorial using the while loop or for loop. Thanks
Expert's answer

using namespace std;
int main()
int j;&
cout << "Enter any number" << endl;
cin >> j;
long nFact = 1L;
if (j < 0)
& return 0L;
else if (j < 2)
& return 1L;
for (long i = j; i > 1; --i)
& nFact *= i;
cout << "Factorial of " << j << " is " << nFact;
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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions