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]
4 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]4 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
Technician A says that 18 gauge AWG wire can carry more current flow that 12 gauge AWG wire. Technician B says that metric wire
denpristay [2]

Answer:

Technician B

Explanation:

Both AWG and metric are sized by cross-sectional area.

Technician A is wrong:  12 gauge wire is larger diameter rated for 20 amps in free air.  18 awg is smaller diameter and typically used for speaker wiring, Class II or low voltage and sub-circuits within appliances.

6 0
3 years ago
A reversible refrigerator operates between a low temperature reservoir at TL and a high temperature reservoir at TH . Its coeffi
Anna11 [10]

Answer

TL/TH- TL

Because we know that power coefficient is. = QL/QH-QL

=so using this for performance we have

=>Perf= TL/(TH-TL)

7 0
3 years ago
Water (cp = 4180 J/kg·°C) enters the 2.5 cm internal diameter tube of a double-pipe counter-flow heat exchanger at 17°C at a rat
aksik [14]

Answer:

Length = 129.55m, 129.55m

Explanation:

Given:

cp of water = 4180 J/kg·°C

Diameter, D = 2.5 cm

Temperature of water in =  17°C

Temperature of water out = 80°C

mass rate of water =1.8 kg/s.

Steam condensing at 120°C

Temperature at saturation = 120°C

hfg of steam at 120°C = 2203 kJ/kg

overall heat transfer coefficient of the heat exchanger = 700 W/m2 ·°C

U = 700 W/m2 ·°C

Since Temperature of steam is at saturation,

temperature of steam going in = temperature of steam out = 120°C

Energy balance:

Heat gained by water = Heat loss by steam

Let specific capacity of steam = 2010kJ/Kg .°C

Find attached the full solution to the question.

3 0
3 years ago
A gear motor can develop 2 hp when it turns at 450rpm. If the motor turns a solid shaft with a diameter of 1 in., determine the
kramer

Answer:

Maximum shear stress is;

τ_max = 1427.12 psi

Explanation:

We are given;

Power = 2 HP = 2 × 746 Watts = 1492 W

Angular speed;ω = 450 rev/min = 450 × 2π/60 rad/s = 47.124 rad/s

Diameter;d = 1 in

We know that; power = shear stress × angular speed

So,

P = τω

τ = P/ω

τ = 1492/47.124

τ = 31.66 N.m

Converting this to lb.in, we have;

τ = 280.2146 lb.in

Maximum shear stress is given by the formula;

τ_max = (τ•d/2)/J

J is polar moment of inertia given by the formula; J = πd⁴/32

So,

τ_max = (τ•d/2)/(πd⁴/32)

This reduces to;

τ_max = (16τ)/(πd³)

Plugging in values;

τ_max = (16 × 280.2146)/((π×1³)

τ_max = 1427.12 psi

7 0
3 years ago
A rigid 10-L vessel initially contains a mixture of liquid and vapor water at 100 °C, with a quality factor of 0.123. The mixtur
masya89 [10]

Answer:

Q_{in} = 46.454\,kJ

Explanation:

The vessel is modelled after the First Law of Thermodynamics. Let suppose the inexistence of mass interaction at boundary between vessel and surroundings, changes in potential and kinectic energy are negligible and vessel is a rigid recipient.

Q_{in} = U_{2} - U_{1}

Properties of water at initial and final state are:

State 1 - (Liquid-Vapor Mixture)

P = 101.42\,kPa

T = 100\,^{\textdegree}C

\nu = 0.2066\,\frac{m^{3}}{kg}

u = 675.761\,\frac{kJ}{kg}

x = 0.123

State 2 - (Liquid-Vapor Mixture)

P = 476.16\,kPa

T = 150\,^{\textdegree}C

\nu = 0.2066\,\frac{m^{3}}{kg}

u = 1643.545\,\frac{kJ}{kg}

x = 0.525

The mass stored in the vessel is:

m = \frac{V}{\nu}

m = \frac{10\times 10^{-3}\,m^{3}}{0.2066\,\frac{m^{3}}{kg} }

m = 0.048\,kg

The heat transfer require to the process is:

Q_{in} = m\cdot (u_{2}-u_{1})

Q_{in} = (0.048\,kg)\cdot (1643.545\,\frac{kJ}{kg} - 675.761\,\frac{kJ}{kg} )

Q_{in} = 46.454\,kJ

3 0
3 years ago
Other questions:
  • Who does the narrator blame for the loss of her job as editor-in-chief? <br> see if i care readworks
    8·2 answers
  • You read a research study that concludes that the higher a student's self-esteem, the better he performs in school. This sort of
    5·1 answer
  • Two AAA-size lithium batteries are connected in series in a flashlight. Each battery has 3.5 volt and 4- Amp-hour capacity. If t
    8·1 answer
  • What gage pressure does a skin diver experience when they dive to 35 ft in the ocean with a water temperature of 55 °F? Report y
    9·1 answer
  • A mercury thermometer has a cylindrical capillary tube with an internal diameter of 0.2 mm. If the volume of the thermometer and
    10·1 answer
  • he Weather Channel reports that it is a hot, muggy day with an air temperature of 90????F, a 10 mph breeze out of the southwest,
    6·1 answer
  • 1. Represent each of the following combinations of units in the correct SI form using the appropriate prefix: (a) μMN, (b) N/μm,
    6·1 answer
  • Why does an aeroplane smoke in the air​
    14·1 answer
  • When an output gear is larger than the input gear the greater ratio is greater than 1 T or F​
    9·1 answer
  • An individual is planning to take an 800-mile trip between two large cities. Three pos-sibilities exist: air, rail, or auto. The
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!