Write a function to compute the distance between two points. Given two points (x1, y1) and (x2, y2), the distance between these points is given by the formula:
You must name the function
distance, and it must return a
double giving the distance between the two points.
(Do not re-type this program. Simply download a copy of the file by right-clicking and choosing "Save link as..." from the context menu. Save it into your normal code folder.)
If you fill in the missing code correctly, your output should like this:
(-2,1) to (1,5) => 5.0 (-2,-3) to (-4,4) => 7.280109889280518 (2,-3) to (-1,-2) => 3.1622776601683795 (4,5) to (4,5) => 0.0
©2013–2015 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.