169k views
4 votes
Assume that a new type called POINT has been defined-- it is a structure consisting of two fields, x and y , both of type double . Assume two variables p1 and p2 of type POINT have been declared . Assume that p1 has already been initialized . Write some code that makes p2 the reflection of p1 : in other words, give p2's x field the value of p1's y field, and give p2's y field, the value of p1's x field.

User Difster
by
6.2k points

1 Answer

3 votes

Answer:

The code to this question can be given as:

Code:

p2.x=p1.y;

p2.y=p1.x;

Explanation:

In the question, it is given that a different type of POINT has been declared that is consisting of two arguments that are x, y. both variable datatype is double and variable p1, p2 are new points that have been declared. In that p1 variable has already been initialized that makes p2 the reflection of p1. So the code can be given above. In this p2.x variable holds the value of the p1.y and p2.y variable holds the value of p1.x.

User JasonYang
by
4.9k points