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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:30, skywil8981
Step 1: choose your topics review the project milestone reflections you submitted for modules 1 through 4. choose the one major idea or concept from each module that you feel most applies to your life. in addition, choose an important concept from module 5 that applies to your life. step 2: write your guidebook for each module: write a catchy headline that clearly and concisely sums up your chosen idea or concept write a brief explanation that includes a description of the concept, why it is important, and how it can be applied to your life to make a positive impact choose an exciting, powerful, or engaging image that illustrates your concept remember, you are writing one for each module, so you will have a total of five headlines, five descriptions, and five images. step 3: design your guidebook choose a format to present your digital guidebook. there are many 21st century tools available for creating and submitting your work in the online environment. for more information on tools your school uses, contact your instructor or visit the web 2.0 tools area.
Answers: 3
image
Computers and Technology, 22.06.2019 01:00, toottoot42169
What can you find the under the privacy policy section of a shopping website?
Answers: 1
image
Computers and Technology, 22.06.2019 10:30, ilovepickles930
What can tanya do now to start preparing for the college and scholarship application process? think about her grades, activities in which she can get involved, possible part-time jobs at which she can work, and standardized tests she can take. (10 points) apex
Answers: 2
image
Computers and Technology, 23.06.2019 03:30, bellsbella34
Ihave a singular monitor that is a tv for my computer. recently, i took apart my computer and put it back together. when i put in the hdmi cord and booted the computer to see if it worked, the computer turned on fine but the screen was blue with "hdmi no signal." i've tried everything that doesn't require buying spare parts, any answer is appreciated!
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 in other subjects:

Konu
Mathematics, 12.11.2019 03:31
Konu
Mathematics, 12.11.2019 03:31
Konu
Mathematics, 12.11.2019 03:31
Konu
Mathematics, 12.11.2019 03:31
Konu
Mathematics, 12.11.2019 03:31