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
Write a program that uses the function isPalindrome given below. Test your program on the following strings: madam, abba, 22, 67
defon

Answer:

#include <iostream>

#include <string>

using namespace std;

bool isPalindrome(string str)

{

   int length = str.length();

   for (int i = 0; i < length / 2; i++)

   {

       if (tolower(str[i]) != tolower(str[length - 1 - i]))

           return false;

   }

   return true;

}

int main()

{

   string s[6] = {"madam", "abba", "22", "67876", "444244", "trymeuemyrt"};

   int i;

   for(i=0; i<6; i++)

   {

       //Testing function

       if(isPalindrome(s[i]))

       {

           cout << "\n " << s[i] << " is a palindrome... \n";

       }

       else

       {

           cout << "\n " << s[i] << " is not a palindrome... \n";

       }

   }    

       

   return 0;

}

5 0
3 years ago
1. A glass window of width W = 1 m and height H = 2 m is 5 mm thick and has a thermal conductivity of kg = 1.4 W/m*K. If the inn
emmasim [6.3K]

Answer:

1. \dot Q=19600\ W

2. \dot Q=120\ W

Explanation:

1.

Given:

  • height of the window pane, h=2\ m
  • width of the window pane, w=1\ m
  • thickness of the pane, t=5\ mm= 0.005\ m
  • thermal conductivity of the glass pane, k_g=1.4\ W.m^{-1}.K^{-1}
  • temperature of the inner surface, T_i=15^{\circ}C
  • temperature of the outer surface, T_o=-20^{\circ}C

<u>According to the Fourier's law the rate of heat transfer is given as:</u>

\dot Q=k_g.A.\frac{dT}{dx}

here:

A = area through which the heat transfer occurs = 2\times 1=2\ m^2

dT = temperature difference across the thickness of the surface = 35^{\circ}C

dx = t = thickness normal to the surface = 0.005\ m

\dot Q=1.4\times 2\times \frac{35}{0.005}

\dot Q=19600\ W

2.

  • air spacing between two glass panes, dx=0.01\ m
  • area of each glass pane, A=2\times 1=2\ m^2
  • thermal conductivity of air, k_a=0.024\ W.m^{-1}.K^{-1}
  • temperature difference between the surfaces, dT=25^{\circ}C

<u>Assuming layered transfer of heat through the air and the air between the glasses is always still:</u>

\dot Q=k_a.A.\frac{dT}{dx}

\dot Q=0.024\times 2\times \frac{25}{0.01}

\dot Q=120\ W

5 0
3 years ago
Air enters a diffuser operating at steady state at 540°R, 15 lbf/in.2, with a velocity of 600 ft/s, and exits with a velocity of
yKpoI14uk [10]

Answer: Hello the question is incomplete below is the missing part

Question:  determine the temperature, in °R, at the exit

answer:

T2= 569.62°R

Explanation:

T1 = 540°R

V2 = 600 ft/s

V1 = 60 ft/s

h1 = 129.0613  ( value gotten from Ideal gas property-air table )

<em>first step : calculate the value of h2 using the equation below </em>

assuming no work is done ( potential energy is ignored )

h2 = [ h1 + ( V2^2 - V1^2 ) / 2 ] * 1 / 32.2 * 1 / 778

∴ h2 = 136.17 Btu/Ibm

From Table A-17

we will apply interpolation

attached below is the remaining part of the solution

8 0
2 years ago
At a certain location, wind is blowing steadily at 10 m/s. Determine the mechanical energy of air per unit mass and the power ge
tangare [24]

Answer:

e= 50 J/kg

Explanation:

Given that

Speed ,v= 10 m/s

Diameter of the turbine = 90 m

Density of the air ,ρ = 1.25 kg/m³

We know that mechanical energy given as

E=\dfrac{1}{2}mv^2\ J

That is why mechanical energy per unit mass will be

e=\dfrac{1}{2}v^2\ J/kg

Now by putting the values in the above equation we get

e=\dfrac{1}{2}\times 10^2\ J/kg

e= 50 J/kg

That why the mechanical energy unit mass will be 50 J/kg.

5 0
3 years ago
Truth table for (A+B)(B+C)
serg [7]

Answer:

A truth table is a logical expression of the given inputs specially in boolean algebra and boolean functions in computer science and digital electronics.

Explanation:

Number of variables are 3 i.e A,B and C

so the number of bits are 2^3=8

A      B     C           A+B               B+C         (A+B)(B+C)

0       0     0             0                   0                    0

0       0      1             0                    1                    0

0       1       0             1                    1                    1

0       1       1              1                    1                    1

1        0      0             1                    0                   0  

1        0      1              1                     1                    1

1        1       0             1                     1                    1

1        1        1             1                     1                    1

5 0
3 years ago
Other questions:
  • During the recovery of a cold-worked material, which of the following statement(s) is (are) true?
    13·1 answer
  • Which of the following is not a primary or fundamental dimension? (a)-mass m (b)-length L (c)- timer t (d)-volume V
    5·1 answer
  • The kinetic energy correction factor depends on the (shape — volume - mass) of the cross section Of the pipe and the (velocity —
    11·1 answer
  • In which forms do MOST of the Sun's energy reach Earth's surface?
    15·1 answer
  • Sam constructs a circuit, connects a lead acid battery of 2 V to a lamp of resistance 3 Ω and places an ammeter across it. What
    8·2 answers
  • A refrigerator operating on the Carnot cycle is used to make ice. Water freezing at 32oF is the cold reservoir. Heat is rejected
    11·1 answer
  • Drag each label to the correct location on the table. Match to identify permanent and temporary structures.
    15·1 answer
  • Hi all any one help me?? ​
    12·2 answers
  • Find the differential and evaluate for the given x and dx: y=sin2xx,x=π,dx=0.25
    13·1 answer
  • 1. What did observations between 1912 and 1917 show?_____
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!