I need some help with this program, it is homework but I can't figure it out. This is what I have to do:
Modify the FACTOR program in this chapter so that it repeatedly asks for a number and calculates its factorial, until
the user enters 0, at which point it terminates. You can enclose the relevent statements in FACTOR in a while loop or a
do loop to achieve this effect.
Here is what I have thus far:
Code:#include <iostream> using namespace std; int main() { unsigned int numb; unsigned long fact=1; //long for larger numbers cout << "Enter a number: "; cin >> numb; //get number for(int j=numb; j>0; j--) //multiply 1 by fact *= j; //numb, numb-1, ..., 2, 1 cout << "Factorial is " << fact << endl; int dummy; cin >> dummy; return 0; }



LinkBack URL
About LinkBacks


