PDA

View Full Version : Factorial



SonniE
06-02-2008, 03:46 PM
White Shadow Sent Me an assignment he had in comp science it was
Description: Write a program that allows the user to enter a number greater than 1. If the number is not greater than one the program will ask then user again, until a valid number is entered. After a good number has been entered the program will tell the user what the factorial of the enter number is.
my version is


//SonniE's Factorial
#include <iostream>
using namespace std;
int main()
{
double num, counter, result;
cout <<"Welcome To SonniE's Factorial App";
there:
cout << "Enter Your Number To See its Factorial\nEnter Number: ";
cin >> num;
result = num;
if (num <= 1)
{
cout << "\nInvalid Entry\n";
goto here;

}
while (num > 1)
{
--num;
result = result* num;
}
cout << "Result: " << result << "\n";
cin.get();
goto there;
here:
return 0;
}