In mathematics, the distance between one point (A) and another point (B), each w
ID: 3643894 • Letter: I
Question
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.Explanation / Answer
Tested in codelab:sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y))
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.