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
yanalaym [24]
3 years ago
7

Write a complete C++ program that is made of functions main() and rShift(). The rShift() function must be a function without ret

urn with 6 parameters. rShift() should do following.1)Shift the first 4 formal parameters' value one place to right circularly and send the updated values out to the caller function, i.e. main. Furthermore, after calling this function with first 4 actual parameters, say a1, a2, a3, a4, and these actual parameters should shift their value one place to right circularly as well. That is, a1 takes a2's value, a2 takes a3's value, a3 takes a4's value, and a4 takes a1's value.2)Assuming that first 4 formal parameters of rShift are n1, n2, n3, and n4, rShift should calculate maximum and average of n1, n2, n3, and n4, and send results back to caller function, i.e. main. The main() function should do following:1)Read four integers from the user with proper prompt and save them to four local variables.2)Call the rShift() function with 6 actual parameters.3)Receive all results, i.e. four shifted integers, plus maximum and average from rShift(). Then print these numbers with proper prompt text. Note:•No input and output with the user inside rShift() function. All input and output should be strictly limited inside main() function.•Both statistics must be calculated with basic C++ flow control statements, and cannot be implemented by calling library functions such as max().

Engineering
1 answer:
erma4kov [3.2K]3 years ago
8 0

Answer:

Explanation:

attached is an uploaded picture to support the answer.

the program is written thus;

#include<iostream>

using namespace std;

// function declaration

void rShift(int&, int&, int&, int&, int&, double&);

int main()

{

   // declare the variables

   int a1, a2, a3, a4;

   int maximum = 0;

   double average = 0;

   // inputting the numbers

   cout << "Enter all the 4 integers seperated by space -> ";

   cin >> a1 >> a2 >> a3 >> a4;

   cout << endl << "Value before shift." << endl;

   cout << "a1 = " << a1 << ", a2 = " << a2 << ", a3 = "  

        << a3 << ", a4 = " << a4 << endl << endl;

   // calling rSift()

   // passing the actual parameters

   rShift(a1,a2,a3,a4,maximum,average);

   // printing the values

   cout << "Value after shift." << endl;

   cout << "a1 = " << a1 << ", a2 = " << a2 << ", a3 = "  

           << a3 << ", a4 = " << a4 << endl << endl;

   cout << "Maximum value is: " << maximum << endl;

   cout << "Average is: " << average << endl;

}

// function to right shift the parameters circularly

// and calculate max, average of the numbers

// and return it to main using pass by reference

void rShift(int &n1, int &n2, int &n3, int &n4, int &max, double &avg)

{

   // calculating the max

   max = n1;

   if(n2 > max)

     max = n2;

   if(n3 > max)

     max = n3;

   if(n4 > max)

     max = n4;

   // calculating the average

   avg = (double)(n1+n2+n3+n4)/4;

   // right shifting the numbers circulary

   int temp = n2;

   n2 = n1;

   n1 = n4;

   n4 = n3;

   n3 = temp;

}

You might be interested in
9. Imagine that you're performing measurements on a circuit with a multimeter. You measure a total circuit
ratelena [41]

Answer:

C

Explanation:

the total resistance is equal to the total potential difference divided by the Current

3 0
2 years ago
Read 2 more answers
Scientific research techniques are used to analyze the effectiveness of political advertising. False True
miv72 [106K]

Answer:

correct me if i'm wrong but i think it's false

Explanation:

5 0
3 years ago
Showing or hiding records in a database is called “filtering.”<br> True<br> False
agasfer [191]

Answer:

TRUE

Explanation:

4 0
2 years ago
Read 2 more answers
What does this work for
Anastaziya [24]

Answer:

it allows your dash board to light up you MPH RPM and all the other numbers on the spadomter

Explanat

8 0
3 years ago
A Rankine steam power plant is considered. Saturated water vapor enters a turbine at 8 MPa and exits at condenser at 10 kPa. The
Ray Of Light [21]

Answer:

0.31

126.23 kg/s

Explanation:

Given:-

- Fluid: Water

- Turbine: P3 = 8MPa , P4 = 10 KPa , nt = 85%

- Pump: Isentropic

- Net cycle-work output, Wnet = 100 MW

Find:-

- The thermal efficiency of the cycle

- The mass flow rate of steam

Solution:-

- The best way to deal with questions related to power cycles is to determine the process and write down the requisite properties of the fluid at each state.

First process: Isentropic compression by pump

       P1 = P4 = 10 KPa ( condenser and pump inlet is usually equal )

      h1 = h-P1 = 191.81 KJ/kg ( saturated liquid assumption )

       s1 = s-P1 = 0.6492 KJ/kg.K

       v1 = v-P1 = 0.001010 m^3 / kg

       

       P2 = P3 = 8 MPa( Boiler pressure - Turbine inlet )

       s2 = s1 = 0.6492 KJ/kg.K   .... ( compressed liquid )

- To determine the ( h2 ) at state point 2 : Pump exit. We need to determine the wok-done by pump on the water ( Wp ). So from work-done principle we have:

   

                           w_p = v_1*( P_2 - P_1 )\\\\w_p = 0.001010*( 8000 - 10 )\\\\w_p = 8.0699 \frac{KJ}{kg}

- From the following relation we can determine ( h2 ) as follows:

                          h2 = h1 + wp

                          h2 = 191.81 + 8.0699

                          h2 = 199.88 KJ/kg

                           

Second Process: Boiler supplies heat to the fluid and vaporize

- We have already evaluated the inlet fluid properties to the boiler ( pump exit property ).

- To determine the exit property of the fluid when the fluid is vaporized to steam in boiler ( super-heated phase ).

              P3 = 8 MPa

              T3 = ?  ( assume fluid exist in the saturated vapor phase )

              h3 = hg-P3 = 2758.7 KJ/kg

              s3 = sg-P3 = 5.7450 KJ/kg.K

- The amount of heat supplied by the boiler per kg of fluid to the water stream. ( qs ) is determined using the state points 2 and 3 as follows:

                          q_s = h_3 - h_2\\\\q_s = 2758.7 -199.88\\\\q_s = 2558.82 \frac{KJ}{kg}

Third Process: The expansion ( actual case ). Turbine isentropic efficiency ( nt ).

- The saturated vapor steam is expanded by the turbine to the condenser pressure. The turbine inlet pressure conditions are similar to the boiler conditions.

- Under the isentropic conditions the steam exits the turbine at the following conditions:

             P4 = 10 KPa

             s4 = s3 = 5.7450 KJ/kg.K ... ( liquid - vapor mixture phase )

             

- Compute the quality of the mixture at condenser inlet by the following relation:

                           x = \frac{s_4 - s_f}{s_f_g} \\\\x = \frac{5.745- 0.6492}{7.4996} \\\\x = 0.67947

- Determine the isentropic ( h4s ) at this state as follows:

                          h_4_s = h_f + x*h_f_g\\\\h_4_s = 191.81 + 0.67947*2392.1\\\\h_4_s = 1817.170187 \frac{KJ}{kg}        

- Since, we know that the turbine is not 100% isentropic. We will use the working efficiency and determine the actual ( h4 ) at the condenser inlet state:

                         h4 = h_3 - n_t*(h_3 - h_4_s ) \\\\h4 = 2758.7 - 0.85*(2758.7 - 181.170187 ) \\\\h4 = 1958.39965 \frac{KJ}{kg} \\

- We can now compute the work-produced ( wt ) due to the expansion of steam in turbine.

                        w_t = h_3 - h_4\\\\w_t = 2758.7-1958.39965\\\\w_t = 800.30034 \frac{KJ}{kg}

- The net power out-put from the plant is derived from the net work produced by the compression and expansion process in pump and turbine, respectively.

                       W_n_e_t = flow(m) * ( w_t - w_p )\\\\flow ( m ) = \frac{W_n_e_t}{w_t - w_p} \\\\flow ( m ) = \frac{100000}{800.30034-8.0699} \\\\flow ( m ) = 126.23 \frac{kg}{s}

Answer: The mass flow rate of the steam would be 126.23 kg/s

- The thermal efficiency of the cycle ( nth ) is defined as the ratio of net work produced by the cycle ( Wnet ) and the heat supplied by the boiler to the water ( Qs ):

                        n_t_h = \frac{W_n_e_t}{flow(m)*q_s} \\\\n_t_h = \frac{100000}{126.23*2558.82} \\\\n_t_h = 0.31

Answer: The thermal efficiency of the cycle is 0.31

       

   

7 0
3 years ago
Other questions:
  • Mike is involved in developing the model building codes that various states and local authorities in the United States adopt. He
    6·1 answer
  • In the 1960s through 1980s, a medical filter manufacturer in Ann Arbor discharged 1,4-dioxane (an industrial solvent) directly i
    10·1 answer
  • A hollow aluminum sphere, with an electrical heater in the center, is used in tests to determine the thermal conductivity of ins
    14·2 answers
  • A PMOS device with VT P = −1.2 V has a drain current iD = 0.5 mA when vSG = 3 V and vSD = 5 V. Calculate the drain current when:
    12·1 answer
  • The displacement volume of an internal combustion engine is 3 liters. The processes within each cylinder of the engine are model
    10·1 answer
  • Name the four ways in which heat is transferred from a diesel engine
    7·1 answer
  • TP-6 What should you do when fueling an outboard boat with a portable tank?
    12·1 answer
  • Define;<br>i) Voltage<br>ii) Current<br>iii) Electrical Power<br>iv) Electrical Energy​
    10·1 answer
  • The size of an engine is called the engine
    13·2 answers
  • Should i show my face?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!