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
gulaghasi [49]
3 years ago
6

7.8.1: Function pass by reference: Transforming coordinates. Define a function CoordTransform() that transforms the function's f

irst 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. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 #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; } 1 test passed All tests passed Run Feedback? How was this section?

Computers and Technology
1 answer:
Lilit [14]3 years ago
7 0

Answer:

Here is the CoordTransform() function:              

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

xValNew = (xVal + 1) * 2;

yValNew = (yVal + 1) * 2; }

The above method has four parameters xVal  and yVal that are used as input parameters and xValNew yValNew as output parameters. This function returns void and transforms its first two input parameters xVal and yVal into two output parameters xValNew and yValNew according to the formula: new = (old + 1) *

Here new variables are xValNew  and yValNew and old is represented by xVal and yVal.

Here the variables xValNew and yValNew are passed by reference which means any change made to these variables will be reflected in main(). Whereas variables xVal and yVal are passed by value.

Explanation:

Here is the complete program:

#include <iostream>

using namespace std;

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

xValNew = (xVal + 1) * 2;

yValNew = (yVal + 1) * 2;}

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; }

The output is given in the attached screenshot   

You might be interested in
What is the correct sequence in which a computer operates​
GrogVix [38]

Answer:

Booting is a startup sequence that starts the operating system of a computer when it is turned on. A boot sequence is the initial set of operations that the computer performs when it is switched on. Every computer has a boot sequence.

8 0
2 years ago
2. Which of the following statements accurately describes enzymes? A. Enzymes increase the activation energy of reactions. B. Te
Bas_tet [7]
B.temperatute and pH can affect how enzymes work
5 0
2 years ago
What makes for a good algorithm compatibility complexity humor correctness efficiency?
Svetlanka [38]
Correctness is key. The other ones are optimizations at most. Although I would always include humor... ;-)
5 0
3 years ago
What is the correct html element for playing video files?
Neko [114]
HTML stands for Hyper Text Markup Language. It is the most commonly language used for <span>creating web pages and web applications. </span>

<span>The correct HTML element for playing video files is <video>.
</span>

To show a video in HTML, use the <video> element:

Example:<span><video<span> width="320" height="240" controls</span>></span>
  <span><source<span> src="video 1.mp4" type="video/mp4"</span>></span>
  <span><source<span> src="movie.ogg" type="video/ogg"</span>></span>
<span></video<span>></span></span>
4 0
2 years ago
Read 2 more answers
What is cloud storage?​
Aleks [24]

Cloud storage is a service model in which data is maintained, managed, backed up remotely and made available to users over a network (typically the Internet).

3 0
3 years ago
Other questions:
  • You can use this effect to break a color into a percentage of its full strength.
    13·1 answer
  • Tower Building Activity
    12·1 answer
  • The entire presentation can be seen at a time in __________
    5·1 answer
  • Microsoft’s SharePoint server product dramatically altered the content and records management (RM) markets. Crocker (2015), edit
    6·1 answer
  • Along a road lies a odd number of stones placed at intervals of 10 metres. These stones have to be assembled around the middle s
    12·1 answer
  • Kevin needs to get his data from a database into a text file to send to another group. He needs to _____.
    12·2 answers
  • Transborder data flow (TDF) restricts the type of data that can be captured and transmitted in foreign countries. True or False
    12·1 answer
  • A ____________ is a collection of commands given a name.
    11·1 answer
  • Which type of file can be opened directly into Excel?
    15·1 answer
  • Transitive spread refers to the effect of the original things transmitted to the associate things through the material, energy o
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!