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
A heat engine operates between 2 reservoirs at TH and 18oC. The heat engine receives 17,000 kJ/h from the high temperature reser
lisabon 2012 [21]

Answer:

See explaination

Explanation:

Please kindly check attachment for the step by step solution of the given problem

4 0
3 years ago
Indicates the design of the building and<br> adjoining areas
Lelu [443]

Answer:

Architectural Plan

Explanation:

4 0
3 years ago
1. Calculate the battery life in years when a pacemaker has the following characteristics: Battery Ampere-hours = 1.5 Pulse volt
Wittaler [7]

Answer:

battery life in year = 9 years and 48 days

Explanation:

given data

Battery Ampere-hours = 1.5

Pulse voltage = 2 V

Pulse width = 1.5 m sec

Pulse time period = 1 sec

Electrode heart resistance = 150 Ω

Current drain on the battery = 1.25 µA

to find out

battery life in years

solution

we get first here duty cycle that is express as

duty cycle = \frac{width}{period}      ...............1

duty cycle = 1.5 × 10^{-3}

and applied voltage will be

applied voltage = duty energy × voltage    ...........2

applied voltage = 1.5 × 10^{-3} × 2

applied voltage = 3 mV

so current will be

current = \frac{applied\ voltage}{resistance}   ................3

current = \frac{3}{150}

current = 20 µA

so net current will be

net current = 20 - 1.25

net current = 18.75 µA

so battery life will be

battery life = \frac{1.5}{18.75*10^{-6}}

battery life = 80000 hours

battery life in year = \frac{80000}{8760}

battery life in year = 9.13 years

battery life in year = 9 years and 48 days

4 0
3 years ago
A cylinder with a frictionless piston contains 0.05 m3 of air at 60kPa. The linear spring holding the piston is in tension. The
AleksAgata [21]

Answer:

18 kJ

Explanation:

Given:

Initial volume of air = 0.05 m³

Initial pressure = 60 kPa

Final volume = 0.2 m³

Final pressure = 180 kPa

Now,

the Work done by air will be calculated as:

Work Done = Average pressure × Change in volume

thus,

Average pressure = \frac{60+180}{2}  = 120 kPa

and,

Change in volume = Final volume - Initial Volume = 0.2 - 0.05 = 0.15 m³

Therefore,

the work done = 120 × 0.15 = 18 kJ

4 0
3 years ago
Advantages, disadvantages and applications of dsb-sc​
allochka39001 [22]

Answer:

<h3>advantages: </h3>

<em>lower power consumption, modulation system is simple</em>

<h3>disadvantages<em>:</em></h3>

<em>complex detection</em>

<h3><em>applications:</em></h3>

analog TV systems: to transmit color information

<h3><em /></h3>

<em />

<em />

<em />

<em />

Explanation:

3 0
3 years ago
Other questions:
  • A soil has the following Green-Ampt parameters Effective porosity 0.400 Initial volumetric moisture content-15% Hydraulic Conduc
    6·1 answer
  • Describe what V1-V4 is
    10·1 answer
  • What the Best describes the purpose of the occupational safety and health administración OSHA
    12·1 answer
  • Under which of the following conditions is a Type B-1 Fire extinguisher required onboard a motorized vessel?
    14·2 answers
  • the frequencies 10, 12, 23 and 45 Hz. (a) What is the minimum sampling rate required to avoid aliasing? (b) If you sample at 40
    13·1 answer
  • Which of the following is part of the highway
    11·2 answers
  • True or False; If I was trying to find the Voltage of my computer, and I was given the Watts and Amps it uses, I would use Watt'
    8·1 answer
  • In plumbing what is a video snake used for
    10·2 answers
  • All people<br><br><br>id 5603642259 pd 123456<br>on z o o m​
    15·1 answer
  • Invent five new communication method wired or wireless you think would be practical
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!