Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Compute the Factorial of a number Compute the Superfactorial of a number Quit #include using namespace std; void getValidUserInputPosNumGT0 (int *a) // this void will

  1. Compute the Factorial of a number
  2. Compute the Superfactorial of a number
  3. Quit
 #include  using namespace std; void getValidUserInputPosNumGT0 (int *a) // this void will pass by reference and store the value chosen by the user. { int num; cout << "Enter in a positive number greater than 0... "; // This is what will print after the switch is done by the code for what the user chooses. cin >> *a; // the integer number the user chooses to use. } long double factorial (int num) // The factorial while calculate the number chosen. { int fact = 1; while (num > 1) { fact *= num; num--; } return fact; } long double SuperFactorial (int num) { { return (num==1 || num==0) ? 1: num * SuperFactorial(num - 1); } return num; } int main () { int ch; int num; cout << "Welcome to the playing with numbers program! "; do { cout << "1) Compute the factorial of a number "; cout << "2) Compute the SuperFactorial of a number "; cout << "3) Quit "; while (true) { cout << "Select an option (1..3).."; cin >> ch; if (ch == 1 || ch == 2 || ch == 3) { break; } } switch (ch) { case 1: getValidUserInputPosNumGT0(&num); cout << "Factorial("<
                        

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

Students also viewed these Databases questions

Question

3. Which nonverbal behaviors, if any, are universal?

Answered: 1 week ago