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]
2 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]2 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
Suppose you have a program P and 90 percent of P can be parallelized, but 10 percent of P is inherently sequential and cannot be
EleoNora [17]

Answer:

Means no matter how many processors you use, speed up never increase from 10 times.

Explanation:

If a problem of size W has a serial component Ws,then performance using parallelism:

Using Amdahl's Law:

Tp = (W - Ws )/ N + Ws

Here, Ws = .1,

W - Ws = .9

Performance Tp = (.9 / N) + .1

---------------------------------------------------------

Speed Up = 1 / ( (.9 / N) + .1)

If N -> infinity, Speed Up <= 10

Means no matter how many processors you use, speed up never increase from 10 times.

5 0
2 years ago
How do you work with collaborators like copywriters developers and project managers?
romanna [79]

Answer:

Have a place for the who team can access all the information they need and use to put their work for project managers to check-up on. Having a when everything is organized in one place, the work will be much smoother.

3 0
2 years ago
How did machines get involved throughout the years?
Nataliya [291]

Answer:

Although the primary goal of a political machine is keeping itself in power rather than providing good government, machines have been responsible for restructuring city governments to centralize authority, improving facilities and services, helping to assimilate immigrant groups, and encouraging the growth of business and industry. Supporters of political machines say that they “work” and that consolidating power in the hands of a boss.

Explanation:a political machine is a political group in which an authoritative leader or small group command the support of a corps of supporters and businesses

4 0
2 years ago
A function defined beginning with void SetNegativesToZeros(int userValues[], ... should modify userValues such that any negative
Stels [109]

Answer:

   public static void setNegativesToZero(int userValues[]){

       System.out.println("Array before setting negatives to zero "+Arrays.toString(userValues));

       for(int i=0; i<userValues.length; i++){

           if(userValues[i]< 1){

               userValues[i] = 0;

           }

       }

       System.out.println();

       System.out.println("Array After setting negatives to zero "+Arrays.toString(userValues));

   }

Explanation:

Using Java programming Language, the method is created to receive an array of ints as parameter (as specified in the question)

Using a for loop, we iterate over the entire array checking for values that are negative (<0) and setting them to zero.

See a complete program below

import java.util.Arrays;

import java.util.Scanner;

public class num1 {

   public static void main(String[] args) {

   // Create an array and assign values

       int [] arr = {1,2,3,-1,1,2,-4};

   //Calling the method setNegativesToZero

   setNegativesToZero(arr);

   }

//Creating the Method

   public static void setNegativesToZero(int userValues[]){

       System.out.println("Array before setting negatives to zero "+Arrays.toString(userValues));

       for(int i=0; i<userValues.length; i++){

           if(userValues[i]< 1){

               userValues[i] = 0;

           }

       }

       System.out.println();

       System.out.println("Array After setting negatives to zero "+Arrays.toString(userValues));

   }

}

3 0
3 years ago
One of the factors that influence the effectiveness of chemical sanitizer works effectively between 13° C and 49° C​
12345 [234]

Answer:

temperature

Explanation:

Temperature is one of the three factors known to have remarkable influence on the effectiveness of chemical sanitizers. These sanitizers generally perform best at temperature range of 13 – 49 degrees centigrade.  

Also, contact time is one of the factors that is needed for the sanitizers to effectively kill the microorganisms. The item to be cleaned should come in contact with the chemical for the recommended period of time.

3 0
2 years ago
Other questions:
  • Which part of the cpu stores instructions for high speed access or processing
    14·1 answer
  • What is unique about being an administrative professional in a government job?
    8·2 answers
  • How many address bits are needed to specify each byte in a 512 byte memory unit?
    5·1 answer
  • Using PowerPoint or Impressed guarantees that your presentation will do which of the following?
    6·1 answer
  • Charts are more effective in attaining attentionthen others methods of presenting data. Do you agree?
    10·1 answer
  • What is TLB for? Why TLB? Given the following number, what is theeffective memory access time?
    11·1 answer
  • Write a program that prompts the user for the name of two files each containing a single line that represents a decimal integerc
    11·1 answer
  • Write a Python program segment, using a loop, to calculate and print the sum of the odd integers from 20 to 120. (Hint: 21 23 25
    13·1 answer
  • 8. Choose the 3 correct statements for the code below.
    11·1 answer
  • Write code that declares a variable named minutes, which holds minutes worked on a job,
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!