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, 23.06.2019 14:00
Select the correct answer. a company is currently focusing on creating specific management goals for itself. which level of maturity is the company demonstrating under the sse_ccm framework? a. performed informally b. planned and tracked c. quantitatively controlled d. well-defined e. continuously improving
Answers: 2
question
Computers and Technology, 23.06.2019 20:50
3.11.3 quiz: comparing and analyzing function typesquestion 4 of 102 pointswhat can you say about the y-values of the two functions f(x) = 3x2-3 andg(x)=2* - 3?
Answers: 2
question
Computers and Technology, 23.06.2019 22:20
If i uninstall nba 2k 19 from my ps4 will my career be gone forever?
Answers: 2
question
Computers and Technology, 24.06.2019 18:10
Most information security incidents will occur because of select one: a. users who do not follow secure computing practices and procedures b. increases in hacker skills and capabilities c. poorly designed network protection software d. increasing sophistication of computer viruses and worms
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
Mathematics, 12.08.2020 08:01
Questions on the website: 13722359