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}

User Shivani Sonagara
by
8.2k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.