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
In a stack data structure, the following items are inserted in the following order: Bob, Alice, Charlie, Eve, Zebra. Then an ite
const2013 [10]

Answer:

Zebra.

Explanation:

Stack is LIFO, so Zebra is added in the last so it will be removed first.

6 0
2 years ago
An easy way to identify the different lines on a chart with different sets of data/information is called a ______________.
Inessa [10]
The answer is B.) Legend
3 0
3 years ago
What is the best most effective way to add your savings account?
earnstyle [38]

Explanation:

to put money in your savings account for college and Car a house and a.bunch of important stuff in life

4 0
2 years ago
One of the most notable and far-reaching programming innovations in radio was the _____ station, a concept that supposedly came
DIA [1.3K]

Answer:

The answer is "Top 40".

Explanation:

The top 40, station is a design concept, that originally comes from viewing jukeboxes. When a customer plays similar songs, that is one of the highlights of these technologies.  

  • It is a new format, that was adopted with great success, and it is also known as pop radio.
  • It is also considered the mainstream music network, which has historically been recognized to be the leading innovator in the Top 40 format.  

5 0
3 years ago
Given an initialized string variable filename write a sequence of statements that append the line all is well to the file whose
LekaFEV [45]

Answer:

Details below...

Explanation:

import java.io.*;  

import java.util.Locale;  

//program to demonstrate PrintWriter  

class PrintWriterDemo {  

public static void main(String[] args)  

 {  

 String s="GeeksforGeeks";  

 // create a new writer  

 PrintWriter out = new PrintWriter(System.out);  

 char c[]={'G','E','E','K'};  

 

 //illustrating print(boolean b) method

 out.print(true);  

 

 //illustrating print(int i) method  

 out.print(1);  

 

 //illustrating print(float f) method  

 out.print(4.533f);  

 

 //illustrating print(String s) method  

 out.print("GeeksforGeeks");  

 out.println();  

 

 //illustrating print(Object Obj) method  

 out.print(out);  

 out.println();  

 

 //illustrating append(CharSequence csq) method  

 out.append("Geek");  

 out.println();  

 

 //illustrating checkError() method  

 out.println(out.checkError());  

 

 //illustrating format() method  

 out.format(Locale.UK, "This is my %s program", s);  

 

 //illustrating flush method  

 out.flush();  

 

 //illustrating close method  

 out.close();  

}  

}  

6 0
3 years ago
Other questions:
  • What are the pros and cons of MP3 audio archives?
    6·1 answer
  • What is the service provided by a third party (such as an ISP) that enables you to connect another cloud directly to your Google
    15·1 answer
  • Int a=10 int b=20<br> A=b<br> The new values for a and b are
    11·2 answers
  • Windows workstations all have elements of server software built-in. What are these elements, and why is the Windows Professional
    9·1 answer
  • IN WHICH COUNTRY DO THEY LET YOU PLAY MINECRAFT IN SCHOOL?
    8·2 answers
  • In Secure Electronic Transaction, the purpose of Dual Signature is to link two messages that are intended for two different reci
    5·1 answer
  • You can't cite Wikipedia, what are three ways that you can use it for your research?
    5·1 answer
  • Que es una red de datos
    7·2 answers
  • True or false scientists investigate and seek to explain the natural world
    14·1 answer
  • This unintelligent brain of mine decided to charge my phone overnight thinking that nothing bad will happen ;-; the next morning
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!