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
Get step-by-step solutions from verified subject matter experts
