The corrected code with pointers should be below.
#include <iostream>
using namespace std;
void swap(int*, int*);
int main()
{
int a, b;
cout << "Enter two number:\nA.";
cin >> a;
cout << "B.";
cin >> b;
swap(&a, &b);
cout << "a,b is now " << a << "," << b << endl;
return 0;
}
void swap(int* x, int* y)
{
*x = (*x) + (*y);
*y = (*x) - (*y);
*x = (*x) - (*y);
}
The sample output is below.
Enter two number:
A.56
B.89
a,b is now 89,56