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
Engineering Questions
valkas [14]
5 is the correct one to choose for this
6 0
3 years ago
Read 2 more answers
g A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output
Nataly [62]

Answer:

# Program is written in Python Programming Language

# Comments are used for explanatory purpose

# Program starts here

# Accept input

Steps = input (Number of Steps: ")

# Calculate distance

distance = float(2000) * float(steps)

#Print Formatted Result

print('%0.2f' % distance)

# End of Program

.--------

The above program converts number of steps to miles.

At line 5, the number of steps is inputted and stored in variable named Steps.

At line 6, the number of miles is calculated by multiplying 2000 by the content of variable Steps

The result is printed at line 8

8 0
3 years ago
Read 2 more answers
The three sub regions of South America are the Andes Mountains, the Amazon Rainforest, and the Eastern Highlands. The Atacama De
Leto [7]

Answer:

<:

Explanation:

8 0
3 years ago
Read 2 more answers
Handsaw teeth are very sharp: to avoid being cut by the teeth, keep hands and fingers well away from the
siniylev [52]
Handsaw teeth are very sharp: to avoid being cut by the teeth, keep hands and fingers well away from the
path of the blade
6 0
3 years ago
Read 2 more answers
A robot was able to detect a burning smell at a shopping mall and prevent a major disaster. Which function enabled the robot to
adelina 88 [10]

Answer:

Smoke detectors on the robot.

Plz rate as Brainliest. I need it to get to the next rank.

3 0
3 years ago
Other questions:
  • A construction manager is looking for workers to build a series of walkways within a large garden apartment. What type of workme
    12·1 answer
  • A parallel circuit with two branches and an 18 volt battery. Resistor #1 on the first branch has a value of 220 ohms and resisto
    7·1 answer
  • A lightweight electric car is powered by ten 12-V batteries. At a speed of 100 km/h, the average frictional force is 1500 N. Wha
    9·1 answer
  • Impact strips may be designed into a bumper cover.<br> True<br> False
    14·1 answer
  • What are the prefixes for 1, 10, 1000, 1,000,000, .1, .01, .001, .000001
    9·1 answer
  • No question but thx<br> reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
    7·2 answers
  • How to install a curt 5th wheel hitch in a 2017 chevy silverado
    14·1 answer
  • It is illegal to improperly dispose of antifreeze.<br> True<br> False
    8·2 answers
  • Is there a project idea, or invention that would be good for<br> my class.
    6·2 answers
  • Which alpha-numeric designator, systematically assigned at the time of manufacture, identifies the manufacturer, month, year, lo
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!