asked 125k views
2 votes
C write function distance that calculates the distance between two points (x1, y1) and (x2, y2). all numbers and return values should be of type double.

1 Answer

4 votes
Your question is unclear but here is my try.

Given (0, 5) and (5, 0), find the distance between the two points.

Let (0, 5) and (5, 0) be the two points.

Let d = distance

d = sqrt{(5 - 0)^2 + (0 - 5)^2}

d = sqrt{(5)^2 + (-5)^2}

d = sqrt{25 + 25}

d = sqrt{50}

d = sqrt{25}•sqrt{2}

d = 5•sqrt{2}

Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.