Question: programming language . + . . + 1/ CLASS WORK - W4 Label it CW4.cpp // Description: Write a program that will find the value

programming language

programming language . + . . + 1/ CLASS WORK - W4

Label it CW4.cpp // Description: Write a program that will find the

. + . . + 1/ CLASS WORK - W4 Label it CW4.cpp // Description: Write a program that will find the value of nl when the user enters n, where n is a non-negative number up to 12 The factorial will calculated 2 ways: (1) With a regular function name Ifactorial (2) With a recursive function named Rfactorial Afterwards print both values and be sure they are equall // 1. Declare the needed variables. There will be one use input) // 2. Immediately call the functions passing the number n // 3. For the Ifactorial use a loop to calculate n! // 4. For the Rfactorial you CANNOT use a loop. // The recursive behavior will handle the computation. // 5. Print both values and check they are equal. // 1/ Note: Recall: 5! = 5 * 4 * 3 * 2 1 - 120 // 0! = 1 // // *** * #include using namespace std; // Header file needed for I/O // Line used for simplicity long Ifactorial(int n); long Rfactorial(int n); // --- int main() // 1. Declare the variables needed for this program int n; long Ifact, Rract; // Because n! generates very large numbers // 2. Call both functions // Write their definitions BELOW the main program // Functions ALWAYS are written below main at this level Ifact Ifactorial(n) Rfact - Rfactorial(n); 77 Non recursive function, line 58 // Recursive function line 65 1/ 3. Print both factorial values --------- // Extra (OPTIONAL - Extra Credit) 17 On a separate .cpp file, label it CW4-extra.cpp 1/ Write a program that will input two numbers A and B, such A B print a message that A must be

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!