Question: c++ language please Modify (this program)* so that it invokes a function to swap the values of two variables. You should use the swapping function

c++ language please

Modify (this program)* so that it invokes a function to swap the values of two variables. You should use the swapping function from (this program)*. The pseudocde for the main() function is as follows:

 input three numbers if first number is greater than second invoke the swap function to swap first and second numbers if first is greater than third invoke the swap function to swap first and third numbers if second is greater than third invoke the swap function to swap second and third numbers output three sorted numbers

(this program)*

int main() {

// inputs the numbers cout << "Enter three numbers: ";

int x, y, z; cin >> x >> y >> z;

int tmp;

// orders x and y if (x > y) { tmp = x; x = y; y = tmp; }

// orders y and z if (y > z) { tmp = y; y = z; z = tmp; }

// orders x and y if (x > y) { tmp = x; x = y; y = tmp; }

// outputs the sorted numbers cout << "The sorted numbers are: "; cout << x << " " << y << " " << z << endl;

return 0; }

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!