Answer:
#include <iostream>
using namespace std;
void CoordTransform(int *xVal, int *yVal) {
// since we have passed x and y by adress:
// any change in xVal or yVal will also change the value of x and y
*xVal = (*xVal + 1) * 2;
*yVal = (*yVal + 1) * 2;
}
int main() {
int x, y;
// geting x from user
cout << "Enter x: ";
cin >> x;
// getting y from user
cout << "Enter y: ";
cin >> y;
// passing x and y to function CoordTransform() by adress.
CoordTransform(&x, &y);
cout << "new x: " << x << endl;
cout << "new y: " << y << endl;
return 0;
}
Step-by-step explanation:
a pointer points to a memory location of the veraible so, when we pass a veriable by adress to a function, any change at that memory location also effect the value of the veriable that is local to the calling function.