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
Plz help me
Dmitrij [34]

As much as the human and physical capital in economy increases, there is a decrease in the marginal gain in economic growth that will diminish.

<u>Explanation:</u>

Low-income countries might have an advantage achieving greater worker productivity and economic growth in the future as their economic growth is faster than the high - income countries.

As much as the human and physical capital in economy increases, there is a decrease in the marginal gain in economic growth that will diminish. And this is called, the laws of diminishing returns.

Secondly, low - income countries find it easier in developing technologies than the high - income technologies especially countries like India and China.

High - income countries put effort in inventing new technologies, whereas low - income countries just improve and improvise their technology.

3 0
3 years ago
Question 2: (a) In your own words, clearly distinguish and differentiate between Ethics in Engineering and Ethics in Computing (
zlopas [31]

Engineering ethics is not without abstraction, but in contrast with computing, it is animated by a robust and active movement concerned with the seamless identification of ethics with practice.

<h3 /><h3>What is engineering?</h3>

This is a branch of science and technology concerned with the design, building, and use of engines, machines, and structures that uses scientific principles.

Comparing ethics in engineering and ethics in computing:

  • Engineering ethics are a set of rules and guidelines. While computing ethics deals with procedures, values and practices.
  • In engineering ethics, engineers must adhere to these rules as a moral obligation to their profession While in computing ethics, the ethics govern the process of consuming computer technology.
  • Following these ethics for the two professions will NOT cause damage, but disobeying them causes damage.

Some practical examples in the computing field:

  • Avoid using the computer to harm other people such as creating a bomb or destroying other people's work.
  • Users also should not use a computer for stealing activities like breaking into a bank or company.
  • Make sure a copy of the software had been paid for by the users before it is used.

Some practical examples in the engineering field:

  • Integrity for oneself.
  • Respect for one another.
  • Pursuit of excellence and accountability.

Hence, Engineering ethics is the field of system of moral principles that apply to the practice of engineering and following them is important to the profession.

Read more about <em>engineering</em> here:

brainly.com/question/17169621

#SPJ1

7 0
2 years ago
What is the mode of operation of a ramp digital voltimeter​
liberstina [14]

Answer:

The operating principle of a ramp type digital voltmeter is to measure the time that a linear ramp voltage takes to change from level of input voltage to zero voltage (or vice versa).

7 0
1 year ago
15 POINTS! Help.
IRISSAK [1]

Answer: it would  overload

Explanation:

4 0
2 years ago
Read 2 more answers
A clean machine is a _______________ machine.
solniwko [45]
A clean machine is a clean machine :-)
4 0
2 years ago
Other questions:
  • WILL MARK BRAINLEST PLEASE HELP
    10·1 answer
  • A polymeric extruder is turned on and immediately begins producing a product at a rate of 10 kg/min. An operator realizes 20 min
    12·1 answer
  • Ten dollars per hour is about how much income per year
    5·2 answers
  • The difference in potential energy between an electron at the negative terminal and one at the positive terminal is called the _
    11·1 answer
  • How many times has the ITU-R revised the CCIR 601 international standard? A. four B. five C. six D. seven
    8·1 answer
  • Three spheres are subjected to a hydraulic stress. The pressure on spheres 1 and 2 is the same, and they are made of the same ma
    8·1 answer
  • When you accelerate, the size of the front tire patch becomes____
    15·1 answer
  • In a long trip what is considered a life line to take with you.
    12·1 answer
  • Engineers please help im not good when it comes to drawing​
    8·1 answer
  • How many squares titles (20cm x 20cm) are needed to coat the sides and base of a pool which is 10m long, 6 meter wide and 3m dee
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!