63 063
Assignments Done
99,1%
Successfully Done
In July 2018

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

#include<iostream>
#include<conio.h>
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;
getch();
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions