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
PLEASE HELP
Zinaida [17]

Answer:

B from you search question carefully and identify the key word

Explanation:

3 0
3 years ago
Read 2 more answers
What is the name of the first practical asymmetric cryptosystem that was created?
victus00 [196]

Answer:

I think the name is RSA

4 0
3 years ago
Ron wants to install an energy efficient and long lasting device for lighting in his new home. Which device should he use?
olga2289 [7]
Ron will most likely want to buy tube lights since that is a good energy saver.
4 0
3 years ago
Read 2 more answers
Aaron bought a photo-editing software package for personal use. He makes two copies of the software, in case the original softwa
Korvikt [17]

Aaron's action is considered legal, as you are allowed to make a backup copy of a legal copy of a software, but it can only be used in case the original software is destroyed or unusable.

5 0
3 years ago
A cell reference in a formula allows you to point to another cell location
mario62 [17]

The cell reference refers to a cell on a worksheet and can be used in a formula to point another location.

Explanation:

A cell reference is a range of cells on a worksheet that can be used in a formula to find the values or data you want to calculate using that formula.

There are two types of cell references relative and absolute. they both behave differently when copied to other cells. Relative references change when a formula is copied to another cell.

Absolute reference remains constant even if they are copied. In a formula multiplications are performed before subtraction.

It does not change when the formula is copied or moved to another cell.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Make the correct match.
    11·1 answer
  • A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
    10·1 answer
  • The chemical symbol H represents which of the following elements?
    9·2 answers
  • Which view is used to allow a publisher to view facing pages of a publication at the same time? Normal Master Page Two-Page Spre
    5·1 answer
  • [17 PTS] What do you think of puzzle games?
    11·1 answer
  • An instruction book or program that takes users through a prescribed series of steps to learn how to use a program is called (a)
    10·1 answer
  • Deleting anitem from a linked list is best when performed using two pointersso that the deleted item is freed from memory.
    7·1 answer
  • PLZ ANSWER THESE QUESTIONS FOR 30 POINTS AND BRAINLIEST!
    9·1 answer
  • 60 POINTS IF YOU GET IT RIGHT
    6·2 answers
  • I have all of the points and brainliest, but it won't level up, I don't know why, anyone know why?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!