Question: QUESTION 3 Swapping two numbers in programming means exchanging the values of two variables. Suppose that we have two variable var1=20 and var2=40. After swapping,

 QUESTION 3 Swapping two numbers in programming means exchanging the values

QUESTION 3 Swapping two numbers in programming means exchanging the values of two variables. Suppose that we have two variable var1=20 and var2=40. After swapping, the value of var1 will become 40 and value of var 2 will become 20. Please consider the two functions below. Select one of these functions that does swapping. Support your choice by providing the outputs for both functions. #include #include void swap2(int px, int py){ int temp; void swap1(int x, int y) { int temp; temp x; ; temp; } temp "px " "px; ; ; temp; } int main() { int var1 int var2 int main() { int var1 = 20; int var2 40; 28; 40; swap2(evari, &var2); swap1(vari, var2); print("vari: %d ", varl); print("var2: %d ", var2); print("vari: %d ", vari); print("var2: %d ", var2); return 0; return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!