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;
}