1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
iris [78.8K]
3 years ago
7

#include using namespace std; void PrintFactorial(int factCounter, int factValue){ int nextCounter; int nextValue; if (factCount

er == 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; /* Your solution goes here */ } } int main() { int userVal; cin >> userVal; cout << userVal << "! = "; PrintFactorial(userVal, userVal); return 0; }

Engineering
1 answer:
bazaltina [42]3 years ago
8 0

Answer:

Check the explanation

Explanation:

Code in C++::

#include <iostream>

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;

/* Your solution goes here */

/**

* We just need to call the function PrintFactorial() recursively

* and pass the two parameters that are just calculated as nextCounter for factCounter

* and nextValue as factValue.

*/

PrintFactorial(nextCounter,nextValue);

}

}

int main() {

int userVal = 0;

userVal = 5;

cout << userVal << "! = ";

PrintFactorial(userVal, userVal);

return 0;

}

Output::

Test Case 1 where userVal=5::

<em><u>Attached Image 1</u></em>

Test Case 2 where userVal=6::

<em><u>Attached Image 1</u></em>

You might be interested in
Car insurance incentives and discounts are available depending on _____. A. school attendance and driver skill B. vehicle type a
WARRIOR [948]

Answer:D. Location, vehicle type, and driving habits

5 0
3 years ago
Read 2 more answers
Complete function PrintPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 3, print "To
weqwewe [10]

Answer:

#include <iostream>

using namespace std;

void PrintPopcornTime(int bagOunces) {

if(bagOunces < 3){

 cout << "Too small";

 cout << endl;

}

else if(bagOunces > 10){

 cout << "Too large";

 cout << endl;

}

else{

 cout << (6 * bagOunces) << " seconds" << endl;

}

}

int main() {

  PrintPopcornTime(7);

  return 0;

}

Explanation:

Using C++ to write the program. In line 1 we define the header "#include <iostream>"  that defines the standard input/output stream objects. In line 2 "using namespace std" gives me the ability to use classes or functions, From lines 5 to 17 we define the function "PrintPopcornTime(), with int parameter bagOunces" Line 19 we can then call the function using 7 as the argument "PrintPopcornTime(7);" to get the expected output.

8 0
3 years ago
The question belongs to Electrical Engineering (Linear System).
-Dominant- [34]
I’m crying looking at that.
5 0
3 years ago
Hi I don't know of yall remeber me, but I'm Jadin aka J. I am looking for my friend group, that I have missed but can't find cau
kirill [66]

Answer:

The young lady was his daughter.The shoemaker was frightened when he saw that she wants to sit near him and took his knife to frighten her and leave him alone to do his work

Explanation:

could uh name them since if i know any i would surely tryin help

7 0
2 years ago
Oxides of nitrogen contribute to the formation of?
Nat2105 [25]

Answer:

B. Acid rain.

C. Photochemical smog.

Explanation:

Oxides of nitrogen contribute to the formation of photochemical smog and acid rain. Photochemical smog is a type of smog produced when ultraviolet light from the sun reacts with nitrogen oxides in the atmosphere while on the other hand, when nitrogen oxide react with the water vapor in the atmosphere forming nitric acid which falls on the earth surface with the help of precipitation.

3 0
3 years ago
Other questions:
  • A circular ceramic plate that can be modeled as a blackbody is being heated by an electrical heater. The plate is 30 cm in diame
    15·1 answer
  • A student is using a 12.9 ft ramp to raise an object 6 ft above the ground.
    5·1 answer
  • The Reynolds number, rhoVD/μ is a very important parameter in fluid mechanics. Determine its value for ethyl alcohol flowing at
    5·1 answer
  • Output all combinations of character variables a, b, and c. If a = 'x', b = 'y', and c = 'z', then the output is: xyz xzy yxz yz
    14·1 answer
  • typedef struct bitNode { int data; struct bitNode *left; struct bstNode *right; } bstNode; int solve(bstNode* root) { if (root =
    15·1 answer
  • A spring-loaded piston-cylinder contains 1 kg of carbon dioxide. This system is heated from 104 kPa and 25 °C to 1,068 kPa and 3
    6·1 answer
  • Mnsdcbjksdhkjhvdskjbvfdfkjbcv hjb dfkjbkjfvvfebjkhbvefgjdf
    7·2 answers
  • Which of the following machine parts always require
    12·1 answer
  • Do the coil resistances have any effect on the plots?
    10·1 answer
  • Airbags may deploy in the<br> of the passenger or<br> driver, or from the<br> of the vehicle.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!