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
Which of the following is likely to have the suffix "" after the domain name in its URL?
vovangra [49]

Answer:

Microsoft is the correct answer

5 0
3 years ago
Read 2 more answers
Suppose a student rubs a Teflon rod with wool and then briefly touches it to an initially neutral aluminum rod suspended by insu
Oliga [24]

Answer:

Due to touch of teflon, its charge will reduce but will not go to zero. Some amount of its initial charge will be transferred to Aluminum rod. So, aluminum rod will have a non-zero negative charge.

Explanation:

3 0
3 years ago
(TCO 4) A system samples a sinusoid of frequency 190 Hz at a rate of 120 Hz and writes the sampled signal to its output without
steposvetlana [31]

Answer:

The frequency that the sampling system will generate in its output is 70 Hz

Explanation:

Given;

F = 190 Hz

Fs = 120 Hz

Output Frequency = F - nFs

When n = 1

Output Frequency = 190 - 120 = 70 Hz

Therefore, if a system samples a sinusoid of frequency 190 Hz at a rate of 120 Hz and writes the sampled signal to its output without further modification, the frequency that the sampling system will generate in its output is 70 Hz

5 0
3 years ago
Chemical manufacturers must present which information on the product's label?
Wewaii [24]

Answer:

hazardous chemicals leaving the workplace is labeled, tagged or marked with the following information: product identifier; signal word; hazard statement

Explanation:

this is so you know what chemicals are in it

6 0
3 years ago
python Write a program that asks a user to type in two strings and that prints •the characters that occur in both strings. •the
Yuliya22 [10]

Answer:

see explanation

Explanation:

#we first get the elements as inputs

x = input("enter string A :")

y = input("enter string B :")

#then we make independent sets with each

x = set(x)

y = set(y)

#then the intersection of the two sets

intersection = set.intersection(x,y)

#another set for the alphabet

#we use set.difference to get the elements present in x and not in y, and

#viceversa, finally we get the difference between the alphabet and the #intersection of the elements in our strings

z = set('abcdefghijklmnopqrstuvwxyz')

print('\nrepeated :\n',intersection)

print('differences :\n',' Items in A and not B\n',

set.difference(x,y),'\nItems in B and not A\n',

set.difference(y,x))

print('\nItems in neither :\n',set.difference(z,intersection))

8 0
3 years ago
Other questions:
  • 2.14 (a) Using series/parallel resistance reductions, find the equivalent resistance between terminals A and B in the circuit of
    14·1 answer
  • What is something that a robot or computer program might do that requires a decision, or conditional statement?
    9·1 answer
  • A 0.9% solution of NaCl is considered isotonic to mammalian cells. what molar concentration is this?
    10·1 answer
  • Hiiiiiiiii<br> jhajwjne f f g. g g tnnjzjnsnsnend f najjwne d f nskiaksjsjsjksm
    5·1 answer
  • How many FastEthernet interfaces does a 2960 switch have?
    7·2 answers
  • Using the following data, determine the percentage retained, cumulative percentage retained, and percent passing for each sieve.
    6·1 answer
  • सत्य से अधिक उपयोगी एवं आज्ञापालन से श्रेष्ठ क्या है ?<br>answer fast plz​
    9·1 answer
  • Raw materials used of silicone rubber
    6·2 answers
  • Technician A says that fuel filler caps with pressure and vacuum vents are used with EVAP system fuel tanks. Technician B says t
    5·1 answer
  • The policeman was questioning the drivers and searching their vehicles. The drivers ____ and their vehicles ____
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!