subject

#include using namespace std; void swap1(int n1, int n2) { int temp = n1; n1 = n2; n2 = temp; } void swap2(int& n1, int& n2) { int temp = n1; n1 = n2; n2 = temp; } void swap3(int* p1, int* p2) { int temp = *p1; *p1 = *p2; *p2 = temp; } void swap4(int* &p1, int* &p2) { int* temp = p1; p1 = p2; p2 = temp; } int main() { int num1 = 1; int num2 = 2; cout << "Before invoking the swap1 function, num1 is " << num1 << " and num2 is " << num2 << endl; swap1(num1, num2); cout << "After invoking the swap1 function, num1 is " << num1 << " and num2 is " << num2 << endl; cout << "Before invoking the swap2 function, num1 is " << num1 << " and num2 is " << num2 << endl; swap2(num1, num2); cout << "After invoking the swap2 function, num1 is " << num1 << " and num2 is " << num2 << endl; cout << "Before invoking the swap3 function, num1 is " << num1 << " and num2 is " << num2 << endl; swap3(&num1, &num2); cout << "After invoking the swap3 function, num1 is " << num1 << " and num2 is " << num2 << endl; int* p1 = &num1; int* p2 = &num2; cout << "Before invoking the swap4 function, p1 is " << p1 << " and p2 is " << p2 << endl; swap4(p1, p2); cout << "After invoking the swap4 function, p1 is " << p1 << " and p2 is " << p2 << endl; return 0; }

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 15:00
Marissa is a high school student who wants to be a hydroelectric production manager. she talks to her guidance counselor about her education path, and the counselor says that she needs to get an associate’s degree from a four-year college and will follow that with significant on-the-job training. what error did the counselor make while advising marissa? marissa will not have on-the-job training. marissa also needs a three-year apprenticeship. marissa only needs to attend a two-year college. marissa needs a bachelor’s degree.
Answers: 1
question
Computers and Technology, 23.06.2019 06:00
Which statistical function in a spreadsheet you to see how far each number varies, on average, from the average value of the list?
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
Which of the following tasks is an audio technician most likely to perform while working on a nature documentary? (select all that apply). eliminating potentially distracting background noise adding sound effects making sure the lighting is adequate for a particular scene changing the narration to better match the mood of the documentary
Answers: 3
question
Computers and Technology, 23.06.2019 13:30
Select the correct answer from each drop-down menu. which types of computer networks are bigger as well as smaller than a man? a man is a network of computers that covers an area bigger than a , but smaller than a .
Answers: 1
You know the right answer?
#include using namespace std; void swap1(int n1, int n2) { int temp = n1; n1 = n2; n2 = temp; } void...
Questions
question
Social Studies, 09.04.2021 05:30
question
Mathematics, 09.04.2021 05:30
question
Mathematics, 09.04.2021 05:30
question
History, 09.04.2021 05:30
question
Mathematics, 09.04.2021 05:30
question
Mathematics, 09.04.2021 05:30
Questions on the website: 13722360