Answer:
#include <iostream> Â
using namespace std; Â
void swapInts(int* x, int* y) {
*x = *x + *y;
*y= *x - *y;
*x = *x - *y; Â
}
int main(){ Â Â
int num1, num2;
cout << "Before swap:";
cin>>num1; Â cin>>num2;
swapInts(&num1, &num2); Â
cout<<"After swap:"<<num1<<" "<<num2;
} Â Â Â
Explanation:
The function begins here:
This line defines the function
void swapInts(int* x, int* y) {
The next three line swap the integer values
*x = *x + *y;
*y= *x - *y;
*x = *x - *y; Â
}
The main begins here:
int main(){ Â
This line declares two integer variables
int num1, num2;
This line prompts the user for inputs before swap
cout << "Before swap:";
This line gets user inputs for both integers
cin>>num1; Â cin>>num2;
This line calls the function
swapInts(&num1, &num2); Â
This prints the numbers after swap
cout<<"After swap:"<<num1<<" "<<num2;
}