Question: Mini-sort with functions. Create a project titled Lab6_Swap . Revisit this program from one of the earlier lab assignments that sorts three numbers in the

Mini-sort with functions. Create a project titled Lab6_Swap. Revisit this program from one of the earlier lab assignments that sorts three numbers in the increasing order. Modify it 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
 Mini-sort with functions. Create a project titled Lab6_Swap. Revisit this program

12:34 vega.cs.kent.edu // demonstrates call-by-reference parameters Walt Savitch 1/ 10/3/00 #include using std: :cout; using std::endl; using std: #cin; void getNumbers (int&, int&) II reads two integers from the keyboard void swap(int&, int&): I/ interchanges first and second parameter void showResults(int, int); /I outputs parameters int main) int firstNm, secondNum; getNumbers (firstNum, secondNum) swap(firstNum, secondNum) : showResults (firstNum, secondNum): // reads two integers from user void getNumbers (int& ini, int& n2) { cout > in 1 >> in2 ; // interchanges left and right void swap (int& left, int& right) const int tmpleft; left = right; right = tmp; // outputs parameters void showResults int outl, int out2) cout

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!