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
What process is used to remove collodal and dissolved organic matter in waste water ​
Juli2301 [7.4K]

Answer:

Aerobic biological treatment process

Explanation:

Aerobic biological treatment process in which micro-organisms, in the presence of oxygen, metabolize organic waste matter in the water, thereby producing more micro-organisms and inorganic waste matter like CO₂, NH₃ and H₂O.

3 0
2 years ago
please help me answer 3 of these questions in complete sentences. this is ccrd 1 related to jobs and college. thanks so much if
Kitty [74]

Answer:

1. Work is a driving force of identity in your life, whether its because it influences you due to the time spent there. Or its truly a passion of yours.

2. Two main aspects of identity development are self-concept and self-esteem

3. Based on you obviously

Hope this helped!

Explanation:

5 0
3 years ago
1. A soil core sampling tube of 4 cm diameter, 12 cm length and initial mass of 0.525 kg (sample only), was dried at 105o C and
belka [17]

Answer:

porosity = 0.07 or 7%

dry bulk density = 3.25g/cm3]

water content =

Explanation:

bulk density = dry Mass / volume of  sample

dry mass = 0.490kg = 490g

volume = πr2h = 3.142 * 2 *2 *12 = 150.8cm3

density = 490/150.8 = 3.25g/cm3

porosity = \frac{wet mass - dry mass }{wet mass} = \frac{0.525 - 0.49}{0.525} = 0.07 or 7%

water content =  \frac{wet mass - dry mass}{wet mass} = 7%

8 0
3 years ago
Read 2 more answers
What to you do if you have a flat tirer
Vika [28.1K]

Answer: change the tires

Explanation: you can’t drive on a flat tire

6 0
3 years ago
Question 74
torisob [31]

Answer:

C). rearview mirror (at least of four inches by four inches).

Explanation:

<u>A 'rearview mirror' would be needed in case one is required to pull an individual on water skis after a PWC(personal watercraft) that is rated for carrying two persons only</u>. This wide-angle mirror for rearview would allow the operator to monitor the person who is being towed constantly along with riding the ski at the same time. It is considered illegal to tow a person on a vessel without having a rearview mirror and at the same time, the limited capacity must also be followed strictly. Hence, <u>option C</u> is the correct answer.

7 0
3 years ago
Other questions:
  • To prevent hydroplaning, _____. A. slow down B. speed up C. deflate your tires D. use cruise control
    15·1 answer
  • Why is it a good idea to lock your doors while driving?<br> WRITER
    10·1 answer
  • Water is the working fluid in a Rankine cycle. Superheated vapor enters the turbine at 8 MPa, 560°C and the turbine exit pressur
    13·1 answer
  • Air expands through an ideal turbine from 1 MPa, 900 K to 0.1 MPa, 500K. The inlet velocity is small compared to the exit veloci
    10·1 answer
  • What must you do if hauling a load of material which could fall or blow onto the roadway?
    14·1 answer
  • An insulated tank having a total volume of 0.6 m3 is divided into two compartments. Initially one compartment contains 0.4 m3 of
    8·1 answer
  • Which part does NOT rotate when the engine is running and the clutch pedal is depressed?
    7·1 answer
  • Nitrogen gas is compressed at steady state from a pressure of 14.2 psi and a temperature 60o F to a pressure of 120 psi and a te
    7·1 answer
  • How did engineers help to create a ceiling fan
    8·1 answer
  • Deviations from the engineering drawing cannot be made without the approval of the
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!