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
Thermal energy generated by the electrical resistance of a 5-mm-diameter and 4-m-long bare cable is dissipated to the surroundin
ella [17]

Answer:

surface temperature = 128.74⁰c

Explanation:

Given data

diameter of cable = 5 mm = 0.005 m

length of cable = 4 m

T∞ ( surrounding temperature ) = 20⁰c

voltage drop across cable ( dv )= 60 V

current across cable = 1.5 A

attached to this answer is the comprehensive analysis and solution to the problem.

The assumption made is not a good one since the calculated Ts ( surface temperature ) is very much different from the assumed Ts

6 0
3 years ago
Discuss the applications of numerical weather forecasting​
olchik [2.2K]

Numerical weather prediction (NWP) uses mathematical models of the atmosphere and oceans to predict the weather based on current weather conditions. Though first attempted in the 1920s, it was not until the advent of computer simulation in the 1950s that numerical weather predictions produced realistic results. A number of global and regional forecast models are run in different countries worldwide, using current weather observations relayed from radiosondes, weather satellites and other observing systems as inputs.
3 0
3 years ago
What is the most important part of a successful Election Day?
wlad13 [49]

Answer: voting of course

Explanation:

8 0
3 years ago
Read 2 more answers
After testing a model of a fuel-efficient vehicle, scientists build a full-sized vehicle with improved fuel efficiency. Which st
Mazyrski [523]
B evaluate the solution. Sorry if I'm wrong.
4 0
3 years ago
 what can be done to prevent bridges from collapsing? ( give at least two examples)
ryzh [129]

Explanation:

the owner of the bridge and some workers

4 0
3 years ago
Other questions:
  • In a study comparing banks in Germany and Great Britain, a sample of 145 matched pairs of banks was formed. Each pair contained
    12·1 answer
  • As of January 1, 2018, Farley Co. had a credit balance of $534,000 in its allowance for uncollectible accounts. Based on experie
    10·1 answer
  • Define ""acidity"" of an aqueous solution. How do you compare the strength of acidity of solutions ?
    6·1 answer
  • The ventilating fan of the bathroom of a building has a volume flow rate of 32 L/s and runs continuously. If the density of air
    7·1 answer
  • PLEASE HELP!!!!!!!!!!!!!!!!!!!!! I AM BEING TIMED!!!!!!!!!!!!!!!!!!!!!! 30 MINUTES LEFT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    7·2 answers
  • You rent an apartment that costs $1800 per month during the first year, but the rent is set to go up 11,5% per year. What would
    12·1 answer
  • Although many countries have issues with soil erosion due to deforestation, some of the most serious effects are seen
    8·1 answer
  • What three training organizations are important for Union Masons?
    14·1 answer
  • ¿Cómo llevan a cabo el lavado ropa?​
    8·1 answer
  • fdkgdsvdgvdfgvsdcvbfbfdbvfdbsdvbesgvdslgfkrledmgoskflodjgloerjgvoljgegjp;erorf;wgp;kiaers;ogjo;rhgerjfrejgfdlhodjglodjheihtgo;rg
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!