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
Engineering Careers Scavenger Hunt
emmasim [6.3K]

Answer:

c

Explanation:

it's the only engineering career

6 0
4 years ago
Read 2 more answers
__________<br> is an accurate way of drawing that shows an object's<br> true size and shape.
Bingel [31]
ANSWER:

Detail drawing
6 0
3 years ago
What forces are not present in space
ss7ja [257]

Answer:

C.) Weight and distance I believe

Explanation:

7 0
3 years ago
A Carnot refrigeration cycle absorbs heat at -12 °C and rejects it at 40 °C. a)-Calculate the coefficient of performance of this
tresset_1 [31]

Answer:

a)COP=5.01

b)W_{in}=2.998 KW

c)COP=6.01

d)Q_R=17.99 KW

Explanation:

Given

T_L= -12°C,T_H=40°C

For refrigeration

  We know that Carnot cycle is an ideal cycle that have all reversible process.

So COP of refrigeration is given as follows

COP=\dfrac{T_L}{T_H-T_L}  ,T in Kelvin.

COP=\dfrac{261}{313-261}

a)COP=5.01

Given that refrigeration effect= 15 KW

We know that  COP=\dfrac{RE}{W_{in}}

RE is the refrigeration effect

So

5.01=\dfrac{15}{W_{in}}

b)W_{in}=2.998 KW

For heat pump

So COP of heat pump is given as follows

COP=\dfrac{T_h}{T_H-T_L}  ,T in Kelvin.

COP=\dfrac{313}{313-261}

c)COP=6.01

In heat pump

Heat rejection at high temperature=heat absorb at  low temperature+work in put

Q_R=Q_A+W_{in}

Given that Q_A=15KW

We know that  COP=\dfrac{Q_R}{W_{in}}

COP=\dfrac{Q_R}{Q_R-Q_A}

6.01=\dfrac{Q_R}{Q_R-15}

d)Q_R=17.99 KW

5 0
3 years ago
a cubical box 20-cm on a side is contructed from 1.2 cm thick concrete panels. A 100-W light bulb is sealed inside the box. What
Flura [38]

Answer:

Temperature on the inside ofthe box

Explanation:

The power of the light bulb is the rate of heat conduction of the bulb, dq/dt = 100 W

The thickness of the wall, L = 1.2 cm = 0.012m

Length of the cube's side, x = 20cm = 0.2 m

The area of the cubical box, A = 6x²

A = 6 * 0.2² = 6 * 0.04

A = 0.24 m²

Temperature of the surrounding, T_0 = 20^0 C = 273 + 20 = 293 K

Temperature of the inside of the box, T_{in} = ?

Coefficient of thermal conductivity, k = 0.8 W/m-K

The formula for the rate of heat conduction is given by:

dq/dt = \frac{kA(T_{in} - T_0)}{L} \\\\100 = \frac{0.8*0.24(T_{in} - 293)}{0.012}\\\\T_{in} - 293 = \frac{100 * 0.012}{0.8*0.24} \\\\T_{in} - 293 = 6.25\\\\T_{in} = 293 + 6.25\\\\T_{in} = 299.25 K\\\\T_{in} = 299.25 - 273\\\\T_{in} = 26.25^0 C

5 0
4 years ago
Other questions:
  • True or False:<br> Less than 2% of the U.S. population make their living producing food and fiber.
    13·1 answer
  • What are Tresca and Von Mises yield criteria?
    14·1 answer
  • Dunno what to ask, okbye
    5·1 answer
  • The cold drawn AISI 1040 steel bar with 25-mm width and 10-mm thick has a 6- mm diameter thru hole in the center of the plate. T
    10·1 answer
  • name the process by which mild steel can be converted into high carbon steel and explain it briefly ?​
    12·1 answer
  • Guess the output of this code: print( (3**2)//2)​
    13·1 answer
  • A heating torch is usually referred to as what?<br><br> Stick<br> Flower<br> Rose-bud<br> Lighter
    15·2 answers
  • Need help, I will give cake :))<br><br> + branliest
    14·2 answers
  • Explain the LWD process why is it important in drilling operations?
    6·1 answer
  • Question 40 and the next Question 41
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!