(Solved) : 3 Program Given File Fix Errors Get Following Program Run Environment B Comment Code Descr Q44059798 . . .
3. In the program given file: A) Fix any errors to get the following program to run in your environment. B) Comment your code and describe any changes you had to make to the original code to get it to work You may also add white space or reorder the code to suit your own style as long as the intended function does not change. /////////////////// Program 2.3 #include <iostream> using namespace std; void swapi(int n, int n2) int temp = n1; nl = 12; n2 = tempi void swap 4 (int* &pl, int* &p2) int* temp = pl; pl = p2; p2 = temp; int main() int num1 = 1; int num2 = 2; cout << “Before invoking the swapl function, numlis” << numi << ” and num2 is ” << num2 << endl; swap1 (numl, num2); cout << “After invoking the swapl function, numlis ” << numl << ” and num2 is ” << num2 << endl; cout << “Before invoking the swap2 function, numlis” << numl <<” and num2 is ” << num2 << endl; swap2 (numl, num2); cout << “After invoking the swap2 function, num1 is ” << numl << ” and num2 is ” << num2 << endl; cout << “Before invoking the swap function, numlis ? << numl << ” and numis ” << num2 << endl; swap3 (&numl, &num2); cout << “After invoking the swap3 function, num1 is ” << numl << ” and num2 is ” << num2 << endl; int* pl = &numl; int* p2 = &num2; cout << “Before invoking the swap4 function, plis” << pl << ” and p2 is ” << p2 << endl; swap 4 (pl, p2); cout << “After invoking the swap ” and p2 is ” << p2 << endl; function, plis ” << pl << void swap2 (int& nl, int& n2) int temp = nl; nl = n2; n2 tempi void swap 3 Cint* pl, int p2) pl; int temp- *pl- “p2; *p2 tempi Show transcribed image text 3. In the program given file: A) Fix any errors to get the following program to run in your environment. B) Comment your code and describe any changes you had to make to the original code to get it to work You may also add white space or reorder the code to suit your own style as long as the intended function does not change.
/////////////////// Program 2.3 #include using namespace std; void swapi(int n, int n2) int temp = n1; nl = 12; n2 = tempi
void swap 4 (int* &pl, int* &p2) int* temp = pl; pl = p2; p2 = temp; int main() int num1 = 1; int num2 = 2; cout
Expert Answer
Answer to 3. In the program given file: A) Fix any errors to get the following program to run in your environment. B) Comment your…
OR