+ Reply to Thread
Results 1 to 1 of 1

Thread: Factorial

  1. #1
    Join Date
    Jan 2008
    Location
    PA
    Posts
    1,164
    Points
    4,027,731.25
    Rep Power
    221

    Default Factorial

    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
    Code:
    //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;
    }
    Attached Files


    Get Vip: »Here«
    Donate: »Here«
    >>List of Compilers<<
    >>SFDM Name Generator<<
    [Owner Of FluidCoding]

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts