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
A teenage brain is already fully developed to enable us to manage risks effectively.
Kisachek [45]

Answer:

false

Explanation:

the brain is only really fully devolved by age 26

3 0
2 years ago
Read 2 more answers
How is the fuel introduced into the Diesel engine?
Ugo [173]

Answer:

diesel fuel is pumped at high pressure to the injectors which are responsible for entering the fuel into the combustion chamber,

when the piston is at the top the pressure is so high that it explodes the fuel (diesel) that results in a generation of mechanical power

5 0
3 years ago
Print a message telling a user to press the letterToQuit key numPresses times to quit. End with newline. Ex: If letterToQuit = '
ella [17]

Answer:

Vb.Net

msgbox ("Press "q" twice to quit", msgboxstyle.information)

if char.q = keypress and keypress.count = 2 then

End

End if

Explanation:

6 0
3 years ago
Consider a voltage v = Vdc + vac where Vdc = a constant and the average value of vac = 0. Apply the integral definition of RMS t
Anna11 [10]

Answer:

Proof is as follows

Proof:

Given that , V = V_{ac} + V_{dc}

<u>for any function f with period T, RMS is given by</u>

<u />RMS = \sqrt{\frac{1}{T}\int\limits^T_0 {[f(t)]^{2} } \, dt  }<u />

In our case, function is V = V_{ac} + V_{dc}

RMS = \sqrt{\frac{1}{T}\int\limits^T_0 {[V_{ac} + V_{dc}]^{2} } \, dt  }

Now open the square term as follows

RMS = \sqrt{\frac{1}{T}\int\limits^T_0 {[V_{ac}^{2} + V_{dc}^{2} + 2V_{dc}V_{ac}] } \, dt  }

Rearranging  terms

RMS = \sqrt{\frac{1}{T}\int\limits^T_0 {V_{dc}^{2}  } \, dt  + \frac{1}{T}\int\limits^T_0 {V_{ac}^{2}  } \, dt  + \frac{1}{T}\int\limits^T_0 {2V_{dc}V_{ac}  } \, dt  }

You can see that

  • second term is square of RMS value of Vac
  • Third terms is average of VdcVac and given is that                      average of  V_{ac}V_{dc} = 0

so

RMS = \sqrt{\frac{1}{T}TV_{dc}^{2}   + [RMS~~ of~~ V_{ac}]^2 }

RMS = \sqrt{V_{dc}^{2}   + [RMS~~ of~~ V_{ac}]^2 }

So it has been proved that given expression for root mean square (RMS) is valid

7 0
3 years ago
Reaming is used for which three of the following functions: (a) accurately locate a hole position, (b) create a stepped hole, (c
Svetlanka [38]

Answer:

b

Explanation:

4 0
3 years ago
Other questions:
  • Does a food market have any rooms in particular? Also whats units?
    10·2 answers
  • A nail that is rectangular in<br> cross section and has a blunt<br> point is called a
    7·1 answer
  • I didn't understand the following matrix manipulation, as shown in the attached photo. How was it done?
    14·1 answer
  • A 75 ohm coaxial transmission line has a length of 2.0 cm and is terminated with a load impedance of 37.5 + j75 Ohm. If the diel
    12·1 answer
  • According to OSHA, employers must_____ and _____ hazardous chemicals in the workplace. Which selection completes the sentence to
    14·1 answer
  • Assume all surface are smooth Draw the FBD for each body
    15·1 answer
  • An automobile travels along a straight road at 15.65 m/s through a 11.18 m/s speed zone. A police car observed the automobile. A
    9·1 answer
  • How can you use the IPDE Process to help protect motorcyclists while driving?
    6·1 answer
  • What kinds of problems or projects would a mechanical engineer work on?
    11·1 answer
  • According to Gary Sirota, the proposed Bajagua wastewater treatment plant is a beneficial solution because __________.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!