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
What is the primary responsibility of ABET?
nalin [4]

Answer:

C

Explanation:

The ABET (Accreditation Board for Engineering and Technology) is a non-governmental organization that accredits programs in applied science, computing, engineering, and engineering technology, both in the United States and elsewhere.

Give Brainliest pls

5 0
3 years ago
If a construction company is considering a new type of material to use in their construction, which factors would they
Amanda [17]

I would honestly select every one of the given options. Gor a company evaluating this new material it would be very valuable to hit each of these factors.

4 0
3 years ago
Which statement linking driving habits and fuel efficiency is true?
Dafna11 [192]

Answer: OC / THE 3 ANSWER

Explanation:

4 0
3 years ago
Which of the following describes what a manufacturing engineer does
oksian1 [2.3K]
Manufacturing Engineers focus on the design and operation of integrated systems for the production of high-quality, economically competitive products.
7 0
3 years ago
Read 2 more answers
2.5 Critically discuss how community needs may influence your choice of a career
GaryK [48]
Different communities will have a demand for different careers. Areas with a large number of school will have a higher demand for teachers. The community needs professors, pays them well, you might decide to choose that path
3 0
3 years ago
Other questions:
  • Here you will program the Newton-Raphson root finding method with details specified as fol-lows. Your code will continue perform
    5·1 answer
  • An oscillating mechanism has a maximum displacement of 3.2m and a frequency of 50Hz. At timet-0 the displacement is 150cm. Expre
    13·1 answer
  • Estimate the design-stage uncertainty in determining the voltage drop across an electric heating element. The device has a nomin
    6·1 answer
  • . On Juan's twenty-sixth birthday, he deposited $7,500 in a retirement account. Each year thereafter, he deposited $1,000 more t
    11·1 answer
  • Programming Assignment 2 Decimal and IEEE-754 ConversionsObjective: To write a C program (not C++) that converts numbers between
    6·1 answer
  • Mild neurotoxins can cause which of these physical effects?
    11·1 answer
  • What is JIT and why would you advocate it to reduce inventory?
    8·1 answer
  • A service station has 10 employees who are responsible for checking in customers who bring their cars in to be serviced. The emp
    14·1 answer
  • If 9 + 10 = 21, then what is 10 + 10?
    8·2 answers
  • State three means of operating a power tool
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!