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]
3 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]3 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
When the atmosphere has too much carbon dioxide in it, the oceans absorb some of it to achieve a new balance. This is an example
horsena [70]
The answer is B. 
A geochemical cycle. 
8 0
4 years ago
Read 2 more answers
Where would you go to access frequently used icons?
trapecia [35]

Answer:

b

Explanation:

4 0
3 years ago
Read 2 more answers
Sophia's plays her favorite game on her phone, where the game uses the phone's
nirvana33 [79]

Answer:

Augmented Reality

Explanation:

Augmented reality is a camera to overlay images on real-world scenery. Basically what the Pokemon GO app does.

8 0
1 year ago
HOW DO YOU RUN YOUR SCRATCH PROGRAM?
kvv77 [185]

Answer:

By clicking on the green flag, it starts up the program and if you want to stop it use the stop sign.

5 0
3 years ago
Read 2 more answers
What would the internet be like today if there was no World Wide Web?
Anvisha [2.4K]

Answer:

Non existent probably

Explanation:

3 0
3 years ago
Other questions:
  • If you could make any blog, what would it be about and why?
    9·1 answer
  • You can create user accounts on the linux system by using the ____ command.
    9·1 answer
  • program that reads numbers from scanf (keyboard) and then sums them, stopping when 0 has been entered. Construct three versions
    14·1 answer
  • Which of the following is NOT a view which can be chosen for a presentation?
    15·1 answer
  • Corey set up his presentation for delivery to his team. The information he had to convey was critical to their job performance.
    6·3 answers
  • A Linux-based OS is called a _____.
    9·1 answer
  • Why was unicode invented?
    10·1 answer
  • Universal Containers uses a custom object within the product development team. Product development, executives, and System Admin
    11·1 answer
  • Why was CDR the most developed country in nepal. Highlight any six reasons​
    9·1 answer
  • You have a filtered dataset for Customer Sales with some null value rows. You want to remove these rows completely. How will you
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!