1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
galina1969 [7]
2 years ago
12

Define a function CoordTransform() that transforms the function's first two input parameters xVal and yVal into two output param

eters 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.
#include
using namespace std;
/* Your solution goes here */
int main() {
int xValNew;
int yValNew;
int xValUser;
int yValUser;
cin >> xValUser;
cin >> yValUser;
CoordTransform(xValUser, yValUser, xValNew, yValNew);
cout << "(" << xValUser << ", " << yValUser << ") becomes (" << xValNew << ", " << yValNew << ")" << endl;
return 0;
}

Computers and Technology
1 answer:
gogolik [260]2 years ago
4 0

Answer:

Here is the function CoordTransform() that transforms the function's first two input parameters xVal and yVal into two output parameters xValNew and yValNew

void CoordTransform (int xVal ,int yVal ,int& xValNew, int& yValNew) { //function definition

xValNew = (xVal +1) *2; // adds 1 to old value (xVal) , multiplies the result by 2 and assigns that new value to xValNew

yValNew = (yVal +1) *2; } // adds 1 to old value (yVal) , multiplies the result by 2 and assigns that new value to yValNew

Explanation:

Here is the complete program:

#include <iostream> //to use input output functions

using namespace std; // to access objects like cin cout

void CoordTransform (int xVal ,int yVal ,int& xValNew, int& yValNew) { //function that takes four arguments

xValNew = (xVal +1) *2; // computes new value and assigns it to xValNew

yValNew = (yVal +1) *2;} // computes new value and assigns it to yValNew

int main() { // start of main function

//declares 4 int type variables xValNew, yValNew, xValUser, yValUser

int xValNew;

int yValNew;

int xValUser;

int yValUser;

cin >> xValUser; // takes value of xValUser from user

cin >> yValUser; // takes value of yValUser from user

CoordTransform(xValUser, yValUser, xValNew, yValNew); //function call

cout << "(" << xValUser << ", " << yValUser << ") becomes (" << xValNew << ", " << yValNew << ")" << endl; //prints the old and new values

return 0;}

In this program the function CoordTransform receives a reference to a variables  xValNew and yValNew so that it can modify the values of these variables. So  xValNew and  yValNew variables are declared as reference so they become an alternative name for the variables xValNew and  yValNew used in main() method . These variables are declared as reference in the function CoordTransform() by placing ‘&’ symbol in the declaration.

Suppose user enters 3 as value of xValUser and 4 as  value of yValUser

Now when the function  CoordTransform() is called it works as follows:

xValNew = (xVal +1) *2; this statement becomes:

xValNew = (3 + 1) * 2

xValNew = 4 * 2

xValNew = 8

Now this value is assigned to the xValNew of calling function (main) xValNew variable.

yValNew = (yVal +1) *2;

this statement becomes:

yValNew = (4 + 1) * 2

yValNew = 5 * 2

yValNew = 10

Now this value is assigned to the yValNew of calling function (main) yValNew variable.

So the output of the above program is:

(3, 4) becomes (8, 10)          

You might be interested in
P**nhub or x-videos or other
Colt1911 [192]
U shouldnt be watching them, Idc how old u are.
3 0
3 years ago
What are the three fundamental principals of mnemonics??
olasank [31]
The three fundamental principles underlying the use of mnemonics are imagination, association and location
4 0
2 years ago
Read 2 more answers
You have installed a device that has eight interfaces and does not forward broadcast packets. What kind of device did you instal
Novay_Z [31]
A router, possibly. Thought I'm not for sure because I'm not in computers and technology

7 0
2 years ago
Read 2 more answers
Please help!! will fan and medal
levacccp [35]
So here are the answers that would best complete the given statements above.
1. <span>The standard resolution for graphics on the Web is 72 dpi.
2. </span> The larger the <span>resolution, the larger the file size.
3. </span>An Inline <span>image is an image that appears on a Web page.
4. File </span><span>size, download times, and the number of colors are factors that will help you decide which graphic format you should use.
5. </span> Adobe Photoshop <span>is an image editing program.
6. The IMG tag </span><span>s used to bring an image into a Web site. 
7. The PNG </span><span>format was the most recently developed popular graphic format. </span>
7 0
3 years ago
Read 2 more answers
Signs that a listener is paying attention include:
Tomtit [17]
Eye contact, Taking notes, being quiet.I mean there is a lot of ways
6 0
3 years ago
Read 2 more answers
Other questions:
  • Where do scanned documents go in windows 10?
    11·1 answer
  • The data I collect in Google Forms are all compiled in a spreadsheet for me.<br> False <br> True
    12·2 answers
  • What is the advantage of defining a target user?
    6·1 answer
  • When was the federal commission act put into effect?????
    13·1 answer
  • Typing which capitals and exclamation points in an email is an example of
    14·1 answer
  • Where is information stored in the computer?​
    9·1 answer
  • Is an automatic computer check to ensure that the data entered is sensible and reasonable.It does not check the accuracy of data
    7·1 answer
  • Write a function solution that, given an array A consisting of N integers, returns the number of fragements of A whose sum equal
    9·1 answer
  • What refers to a collection of small sections of code that are stored together to solve many everyday programs?
    11·2 answers
  • ______________ are used to store information that will be referenced and manipulated in a computer program. They label data with
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!