C++ code-- Factorial Recursion Write code to complete PrintFactorial()'s recursive case. Sampleoutput if userVal is 5: 5! = 5 * 4 * 3 * 2 * 1 = 120 #include using namespace std; void...



C++ code-- Factorial Recursion


Write code to complete PrintFactorial()'s recursive case. Sample output if userVal is 5:


5! = 5 * 4 * 3 * 2 * 1 = 120 #include using namespace std; void PrintFactorial(int factCounter, int factValue){ int nextCounter = 0; int nextValue = 0; if (factCounter == 0) { // Base case: 0! = 1 cout < "1"="">< endl;="" }="" else="" if="" (factcounter="=" 1)="" {="" base="" case:="" print="" 1="" and="" result="" cout="">< factcounter="">< "=" << factValue << endl; } else { // Recursive case cout << factCounter << " *="" ";="" nextcounter="factCounter" -="" 1;="" nextvalue="nextCounter" *="" factvalue;="" }="" }="" int="" main()="" {="" int="" userval="0;" userval="5;" cout="">< userval="">< "! = "; printfactorial(userval, userval); return 0; }
"!="">
>
Nov 11, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here