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, 22.06.2019 00:30
Jenny wants to look at row 345 and compare it to row 17. what can she do if she wanted to easily adjust to see both at once?
Answers: 3
question
Computers and Technology, 22.06.2019 06:30
Requirement types discussed during software development include functional and color scheme nonfunctional and code style constraint and nonfunctional fashionable and functional.
Answers: 2
question
Computers and Technology, 22.06.2019 12:30
What characteristic of long period comets suggest they come directly from the oort cloud?
Answers: 2
question
Computers and Technology, 24.06.2019 10:00
In which view can you see speaker notes?
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
Geography, 21.10.2020 14:01
question
English, 21.10.2020 14:01
question
English, 21.10.2020 14:01
question
English, 21.10.2020 14:01
question
Geography, 21.10.2020 14:01
question
Chemistry, 21.10.2020 14:01
Questions on the website: 13722367