Question: C++ program: Write a program that prompts the user to enter four different integers. The program then calls a function named largest_and_Smallest that has six

C++ program:

Write a program that prompts the user to enter four different integers. The program then calls a function named largest_and_Smallest that has six parameters in its header: the first four are value parameters that accepts and stores a copy of the four integers passed to the function from the main(); the remaining two must be reference parameters that returns the values of the largest and the smallest of the four integers. Notice that the function prototype is intentionally not provided so that you get a chance to go through the thinking process.

So far I have this but I don't know where to go from there:

#include

using namespace std;

int main(){

int n1, n2, n3, n4;

cout << "Please enter three different integers." << endl;

cin >> n1 >> n2 >> n3 >> n4;

}

int largest_and_Smallest(num1, num2, num3, num4, &merge, &small)

{

if (num1 < num2)

{

small = num1;

large = num2;

}

else

{

small = num2;

large = num1;

}

if (num3 < small)

small = num3;

else if (num3 > large)

large = num3;

if (num4 < small)

small = num4;

else if (num4 > large)

large = num4;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!