![]() |
VOOZH | about |
You are given two coordinates (x1, y1) and (x2, y2) of a two-dimensional graph. Find the distance between them.
Examples:
Input : x1, y1 = (3, 4)
x2, y2 = (7, 7)
Output : 5
Input : x1, y1 = (3, 4)
x2, y2 = (4, 3)
Output : 1.41421
We will use the distance formula derived from Pythagorean theorem. The formula for distance between two point (x1, y1) and (x2, y2) is
Distance =
We can get above formula by simply applying Pythagoras theorem
Below is the implementation of above idea.
1.41421