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
A BS of 5.43 ft is taken on a level rod at a 120-ft distance, and a FS of 8.76 ft is taken on the rod held 1,100 feet away.(a) W
jok3333 [9.3K]

Answer:

The answer is attached below

Explanation:

3 0
4 years ago
For some metal alloy, a true stress of 345 MPa (50040 psi) produces a plastic true strain of 0.02. How much will a specimen of t
Strike441 [17]

Answer:

the elongation of the metal alloy is 21.998 mm

Explanation:

Given the data in the question;

K = σT/ (εT)ⁿ

given that metal alloy true stress σT = 345 Mpa, plastic true strain εT = 0.02,

strain-hardening exponent n = 0.22

we substitute

K = 345 / 0.02^{0.22

K = 815.8165 Mpa

next, we determine the true strain

(εT) = (σT/ K)^1/n

given that σT = 412 MPa

we substitute

(εT) = (412 / 815.8165 )^(1/0.22)

(εT) = 0.04481 mm

Now, we calculate the instantaneous length

l_i = l_0e^{ET

given that l_0 = 480 mm

we substitute

l_i =480mm × e^{0.04481

l_i =  501.998 mm

Now we find the elongation;

Elongation = l_i - l_0

we substitute

Elongation = 501.998 mm - 480 mm

Elongation = 21.998 mm

Therefore, the elongation of the metal alloy is 21.998 mm

6 0
3 years ago
Give five general principles involved in the process of sewage filtration?​
aleksandr82 [10.1K]

Answer:

Some general principles are given below in the explanation segment.

Explanation:

Sewage treatment seems to be a method to extract pollutants from untreated sewage, consisting primarily of domestic sewage including some solid wastes.

<u>The principles are given below:</u>

  • Unless the components throughout the flow stream become greater than the ports or even the gaps throughout the filter layer, those holes would be filled as either a result of economic detection.
  • The much more common element of filtration would be the use of gravity to extract a combination.
  • Broadcast interception or interference.  
  • Inertial influence.
  • Sieving seems to be an excellent method to distinguish particulates.

8 0
3 years ago
Explain Flags in ARM Processor​
kipiarov [429]

Answer:

The ARM processor normally contains at least the Z, N, C, and V flags, which are updated by execution of data processing instructions.

Explanation:

3 0
3 years ago
__________<br> is an accurate way of drawing that shows an object's<br> true size and shape.
Bingel [31]
ANSWER:

Detail drawing
6 0
3 years ago
Other questions:
  • An insulated piston–cylinder device initially contains 1 m3 of air at 120 kPa and 17°C. Air is now heated for 15 min by a 200-W
    7·1 answer
  • An aquifer has three different formations. Formation A has a thickness of 8.0 m and hydraulic conductivity of 25.0 m/d. Formatio
    9·1 answer
  • Is there a way to get the answers to a NCCER book test?
    7·1 answer
  • With a reservoir pressure of 1.0 MPa and temperature of 750 K, air enters a converging-diverging nozzle, in a steady fashion. Fl
    5·1 answer
  • Describing Tasks for Stationary Engineers Click this link to view O*NET’s Tasks section for Stationary Engineers. Note that comm
    12·2 answers
  • Find all the words, Figure out my puzzle!
    14·2 answers
  • HELP ME PLEASE RN
    8·1 answer
  • Can someone please help me with this <br>I've an exams tomorrow ​
    7·1 answer
  • What material are the rocker/valve cover gaskets made out of?
    5·1 answer
  • What is the tolerance for number 4?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!