Computers and Technology, 19.10.2019 11:30 Deemon
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;
}
Answers: 2
Computers and Technology, 22.06.2019 16:10
When copying and pasting text, the first step is move your cursor type the text select the copy command select the paste command
Answers: 2
Computers and Technology, 23.06.2019 13:30
Anetwork security application that prevents access between a private and trusted network and other untrusted networks
Answers: 1
Computers and Technology, 23.06.2019 16:30
What is one reason why indoor air pollution has become an increasing problem.
Answers: 1
Computers and Technology, 24.06.2019 23:30
Which example can be considered master data in an organization? a. holiday list b. dress code c. employee information d. recreational activities
Answers: 1
C++ code-- factorial recursion
write code to complete printfactorial()'s recursive case. sampl...
write code to complete printfactorial()'s recursive case. sampl...
Mathematics, 26.02.2020 08:07
English, 26.02.2020 08:07
History, 26.02.2020 08:07
History, 26.02.2020 08:07
Social Studies, 26.02.2020 08:07
Biology, 26.02.2020 08:09
Physics, 26.02.2020 08:09
English, 26.02.2020 08:10
History, 26.02.2020 08:10
Mathematics, 26.02.2020 08:10
Mathematics, 26.02.2020 08:10
Social Studies, 26.02.2020 08:10
Spanish, 26.02.2020 08:10