Write the following program in C++ Define a function CoordTransform() that trans
ID: 3923717 • Letter: W
Question
Write the following program in C++ Define a function CoordTransform() that transfors its first two input parameters x Val and y Val into two output parameters x ValNew and y ValNew. The function returns void. The transformation is new = (old + 1) *2. Ex: If xVal = 3 and yVal = 4, then xValNew is 8 and y ValNew is 10. Identify the types and the nubmer of inputs variables Define function prototyp Define the function # include using namespace std;/* Your prototype goes here */int main() {int x ValNew = 0; int y ValNew = 0; CoordTransform(3, 4, x ValNew, y ValNew);coutExplanation / Answer
1. Types and Number of variables
Type
Number of variables =4
2. Function prototype is the declaration of funcion where we declare return type , number and type of arguments.
#include <iostream>
using namespace std;
void CoordTransform(int,int,int*,int*); //Function Prototype
int main()
{
int xValNew=0;
int yValNew=0;
CoordTransform(3,4,&xValNew,&yValNew); //function call
cout<<"(3,4) becomes"<< "(" <<xValNew<<","<<yValNew<<")"<<endl;
return 0;
}
void CoordTransform(int xVal,int yVal,int *xValNew,int *yValNew) //function definition
{
*xValNew = (xVal + 1)*2;
*yValNew = (yVal + 1)*2;
}
Output:
Success time: 0 memory: 3468 signal:0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.