Define a function CoordTransform() that transforms the function's first two input parameters xVal and yVal into two output parameters xValNew and yValNew. The function returns void. The transformation is new

Respuesta :

Complete Question:

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.

Answer:

The function written in C++ is as follows:

void CoordTransform(int xVal, int yVal) {

   int xValNew = (xVal + 1) * 2;

   int yValNew = (yVal + 1) * 2;

   cout<<"New x: "<<xValNew<<endl;

   cout<<"New y: "<<yValNew;

}

Explanation:

This line defines the function

void CoordTransform(int xVal, int yVal) {

This line declares and calculates xValNew

   int xValNew = (xVal + 1) * 2;

This line declares and calculates yValNew

   int yValNew = (yVal + 1) * 2;

This line prints xValNew

   cout<<"New x: "<<xValNew<<endl;

This line prints yValNew

   cout<<"New y: "<<yValNew;

}

See attachment for complete program that includes the main method

Ver imagen MrRoyal