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
Workers who work with what kind of chemicals chemicals may require regular medical checkups on a more frequent basis as a result
vazorg [7]
Workers who work with TOXIC chemicals may require regular medical checkups on a more frequent basis as a result of contact.
8 0
2 years ago
If my friend have the corona what do I do
nordsb [41]
(E. Call the hospital to take them away
5 0
3 years ago
Read 2 more answers
Joinn my zo om lets play some blookets<br> 98867 708157<br> 9dPQPW
pav-90 [236]

Answer:k

Explanation:

6 0
2 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
Emergency plans are being formulated so that rapid action can be taken in the event of an equipment failure. It is predicted tha
chubhunter [2.5K]

Answer:

Ammonia gas a hazardous gas to our health, when we are exposed to it for a long time. The gas is lighter than air, that means it's high concentration may not be noticed at the point of leakage, because it flows with the wind direction. Ammonia gas detector are used to determine the concentration of the gas at a particular place. We can use the dispersion modelling software program to know the exact position, where we can place the gas detector, which would be where evacuation is needed.

During evacuation, when the concentration of the gas has increased, a self-contained breathing apparatus should be used for breathing, and an encapsulated suit should be worn to prevent ammonia from reacting with our sweat or any other chemical burn. A mechanic ventilation will also be needed in the place of evacuation, so that the ammonia concentration in that area can be dispersed.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Whenever you are around construction sites, you should A speed up so you get through it quicker and avoid falling rocks B maneuv
    10·1 answer
  • Show from the first principles that, for a perfect gas with constant specific heat capacities
    14·1 answer
  • Compute the fundamental natural frequency of the transverse vibration of a uniform beam of rectanqular cross section, with one e
    11·2 answers
  • Use the drop-down menus to choose the correct term or words to complete the statements.
    10·1 answer
  • Please Help It's really Important
    12·1 answer
  • Write a function called pyramid(height) that acceptsa parameter ""height"". It then prints a pyramid of that height
    10·1 answer
  • What would be the most likely scale factor to use for an n-gauge model train setup? (An n-gauge layout uses locomotives that are
    8·1 answer
  • Assess the capabilities of a hydroelectric power plant from the following field data: Estimated water flow rate, 40 m3/s River i
    9·1 answer
  • What would happen if the brake pedal was released while the bleed screw was open during brake bleeding?
    7·1 answer
  • A 1/4" nut driver with a 1.52 inch diameter handle is used to install a 14" 6 UNC
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!