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. Assume that Point has already been defined as a structured type with two double fields, x and y. Define a function dist that takes two Point arguments and returns the distance between the points they represent.

LANGUAGE: C++

CHALLENGE:

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. Assume that Point has already been defined as a structured type with two double fields, x and y. Define a function dist that takes two Point arguments and returns the distance between the points they represent.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,