C++ question from myprogramminglab.com
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.
In mathematics, the distance between one point (A) and another point (B), each with coordinates (x,y), can be computed by taking the differences of their x coordinates and their y coordinates and then squaring those differences. The squares are added and the square root of the resulting sum is taken and... voila! The distance. Given two variables, p1 and p2 that are of type POINT -- a structured type with two fields, x and y, both of type double-- write an expression whose value is the distance between the two point represented by p1 and p2.