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
3. A 4-m × 5-m × 7-m room is heated by the radiator of a steam-heating system. The steam radiator transfers heat at a rate of 10
Natali [406]

Answer:

14.52 minutes

<u>OR</u>

14 minutes and 31 seconds

Explanation:

Let's first start by mentioning the specific heat of air at constant volume. We consider constant volume and NOT constant pressure because the volume of the room remains constant while pressure may vary.

Specific heat at constant volume at 27°C = 0.718 kJ/kg*K

Initial temperature of room (in kelvin) = 283.15 K

Final temperature (required) of room = 293.15 K

Mass of air in room= volume * density= (4 * 5 * 7) * (1.204 kg/m3) = 168.56kg

Heat required at constant volume: 0.718 * (change in temp) * (mass of air)

Heat required = 0.718 * (293.15 - 283.15) * (168.56) = 1,210.26 kJ

Time taken for temperature rise: heat required / (rate of heat change)

Where rate of heat change = 10000 - 5000 = 5000 kJ/hr

Time taken = 1210.26 / 5000 = 0.24205 hours

Converted to minutes = 0.24205 * 60 = 14.52 minutes

4 0
4 years ago
QUESTION:
pentagon [3]
74 cycles it’s what u need
7 0
3 years ago
If a generator has 120 volts and 22 amps, how many ohms are needed so the generator will not explode.
daser333 [38]
120 volt divided by 22 ampere
= 5.4545454545455 ohm (Ω)
P = V × I
= 120 volt × 22 ampere
= 2640 watt (W)
7 0
3 years ago
Now that we have a second enemy, you will need to make some changes to the script that is attached to your backdrop. Look at tha
JulsSmile [24]

Answer:

<u><em>≡</em></u>

Explanation:

8 0
3 years ago
2. Ackermann's Function is a recursive mathematical algorithm that can be used to test how well a system optimizes its performan
oee [108]

The python program is an implementation of the Ackermann function that a system optimizes its performance of recursion.

As per the question,

Here is an implementation of the Ackermann function in Python:

<em />

<em>def ackermann(m, n):</em>

<em>    if m == 0:</em>

<em>        return n + 1</em>

<em>    elif n == 0:</em>

<em>        return ackermann(m - 1, 1)</em>

<em>    else:</em>

<em>        return ackermann(m - 1, ackermann(m, n - 1))</em>

<em />

<em># get input values for m and n from the user</em>

<em>m = int(input("Enter an integer value for m: "))</em>

<em>n = int(input("Enter an integer value for n: "))</em>

<em />

<em># calculate and print the result of the Ackermann function</em>

<em>result = ackermann(m, n)</em>

<em>print("Ackermann ({},{}) = {}".format(m, n, result))</em>

This implementation follows the logic described in the prompt, using a recursive function to calculate the result of the Ackermann function for the given values of m and n.

To learn more about the Python Program click here:

brainly.com/question/15061326

#SPJ1

<em />

5 0
1 year ago
Other questions:
  • A freshwater jet boat takes in water through side vents and ejects it through a nozzle of diameter D = 75 mm; the jet speed is V
    5·1 answer
  • The correct statement about the lift and drag on an object is:_______
    7·2 answers
  • The air contained in a room loses heat to the surroundings at a rate of 50 kJ/min while work is supplied to the room by computer
    11·2 answers
  • Part of the following pseudocode is incompatible with the Java, Python, C, and C++ language Identify the problem. How would you
    12·1 answer
  • name the process by which mild steel can be converted into high carbon steel and explain it briefly ?​
    12·1 answer
  • The website of a bank that an organization does business with has been reported as untrusted by the organization's web browser.
    12·1 answer
  • PLEASE HELP
    15·2 answers
  • ILL GIVE BRAINLIEST!!!
    11·1 answer
  • Câu 1: Tìm từ trong 2 câu thơ sau liên quan đến các từ: hình chiếu, tia chiếu, mặt phẳng chiếu.
    12·1 answer
  • You should use the pass technique a fire extinguisher
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!