- #1
Colton0117
- 5
- 0
Define a function CoordTransform() that transforms its first two input parameters xVal and yVal into two output parameters xValNew and yValNew. The function returns void. The transformation is new = (old + 1) * 2. Ex: If xVal = 3 and yVal = 4, then xValNew is 8 and yValNew is 10.
My code:
My output is (3, 4) becomes (0, 0) when it should be (8, 10), what am I missing or overlooking to operate the void and have x or y ValNew hold its value?
My code:
Code:
#include <iostream>
using namespace std;
void CoordTransform(int xVal , int yVal , int xValNew, int yValNew){
xValNew = (xVal +1) *2;
yValNew = (yVal +1) *2;
return;
}
int main() {
int xValNew = 0;
int yValNew = 0;
CoordTransform(3, 4, xValNew, yValNew);
cout << "(3, 4) becomes " << "(" << xValNew << ", " << yValNew << ")" << endl;
return 0;
}
My output is (3, 4) becomes (0, 0) when it should be (8, 10), what am I missing or overlooking to operate the void and have x or y ValNew hold its value?