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]
4 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]4 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
Air is compressed from 100 kPa, 300 K to 1000 kPa in a two-stage compressor with intercooling between stages. The intercooler pr
Brut [27]

Answer:

The total compressor work is 234.8 kJ/kg for a isentropic compression

Explanation:

Please look at the solution in the attached Word file

Download docx
6 0
4 years ago
Help me pls with tools
irina1246 [14]

Answer:

How?

Explanation:

3 0
4 years ago
Read 2 more answers
True or False; The Neutrons in an atom have a neutral charge.​
yanalaym [24]

Answer:

true

Explanation:

if it is not true it is false

3 0
3 years ago
Read 2 more answers
A piston–cylinder assembly contains propane, initially at 27°C, 1 bar, and a volume of 0.2 m3. The propane undergoes a process t
iren2701 [21]

Work done = -19.7 KJ

Heat transferred = 17.4 KJ

Explanation:

Given-

Temperature, T = 27°C

Volume, V = 0.2 m³

Pressure, P_{1}= 1 bar

v_{2} = 4 bar

pV¹°¹ = constant

From superheated propane table, at  P_{1}= 1 bar andT_{1}  = 27⁰C

v_{1} = 0.557 m³/kg

v_{2} = 473.73 KJ/kg

(a) Work = ?

We know,

V1¹°¹ = p2V2¹°¹

V2 = (\frac{P1}{P2})^\frac{1}{1.1} * V1  \\\\V2 = \frac{1}{4}^\frac{1}{1.1} * 0.557  \\\\V2 = 0.158 m^3/kg

At  = 4 bar and v = 0.158 m³/kg

u2 = 548.45K J/kg

To find work done in the process:

W = \frac{P2V2 - P1V1}{1-n} \\\\W = \frac{m(P2V2 - P1V1)}{1-n} \\\\W = \frac{v}{u} * \frac{P2V2 - P1V1}{1-n}\\  \\W = \frac{0.2}{0.5571} * \frac{4 X 0.158 - 1 X 0.577}{1-1.1} X 10^5 \frac{Pa}{Bar} \frac{1KJ}{10^3Nm} \\   \\W = -19.75KJ

(b) Heat transfer = ?

Q = m(u2 - u1) + W\\\\Q = \frac{0.2}{0.5571} * (548.45 - 473.73) + (-19.7)\\\\Q = 17.4KJ

8 0
4 years ago
Here, we want to become proficient at changing units so that we can perform calculations as needed. The basic heat transfer equa
netineya [11]

Answer:

9500 kJ; 9000 Btu

Explanation:

Data:

m = 100 lb

T₁ = 25 °C

T₂ = 75 °C

Calculations:

1. Energy in kilojoules

ΔT = 75 °C - 25 °C = 50 °C  = 50 K

m = \text{100 lb} \times \dfrac{\text{1 kg}}{\text{2.205 lb}} \times \dfrac{\text{1000 g}}{\text{1 kg}}= 4.54 \times 10^{4}\text{ g}\\\\\begin{array}{rcl}q & = & mC_{\text{p}}\Delta T\\& = & 4.54 \times 10^{4}\text{ g} \times 4.18 \text{ J$\cdot$K$^{-1}$g$^{-1}$} \times 50 \text{ K}\\ & = & 9.5 \times 10^{6}\text{ J}\\ & = & \textbf{9500 kJ}\\\end{array}

2. Energy in British thermal units

\text{Energy} = \text{9500 kJ} \times \dfrac{\text{1 Btu}}{\text{1.055 kJ}} = \text{9000 Btu}

7 0
3 years ago
Other questions:
  • Decide whether or not the Final Value Theorem is applicable to the following functions. If not, indicate why you cannot apply it
    11·1 answer
  • A storm sewer is carrying snow melt containing 1.2 g/L of sodium chloride into a small stream. The stream has a naturally occurr
    14·1 answer
  • Tadpoles raised in water with atrazine levels of 0.1 ppb should produce a higher percentage of male frogs with gonadal abnormali
    13·1 answer
  • Problem 1 A coil measures ???? ???????? ⁄ meter in length with 500 turns of ???? ???? ⁄ inch diameter, and has a metallic core w
    13·1 answer
  • Water flows at a rate of 0.040 m3/s in a 0.12-m-diameter pipe that contains a sudden contraction to a 0.06-m-diameter pipe. Dete
    14·1 answer
  • Apply the particle under a net force model to the block in the horizontal direction:1) Fx = F cos θ - fk - T = m2ax = m2aApply
    15·1 answer
  • There are three basic methods of transmitting power as a. Electronical, mechanical, and fluid power b. Electical, mechanical, an
    10·1 answer
  • (30 pts) A simply supported beam with a span L=20 ft and cross sectional dimensions: b=14 in; h=20 in; d=17.5 in. is reinforced
    13·1 answer
  • What were some of the challenges to safety resulting from such radical airframe designs as highly swept wings, high wing loading
    15·1 answer
  • How can the use of local materials improve the standard of living of Filipinos?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!