distance formula

I am trying to write a function that calculates the Euclidian distance between two points described by
𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 = √(𝑥1 − 𝑥2)2 + (𝑦1 − 𝑦2)2
Input Prompt
Enter x1, y1, and x2, y2:
Output Prompt
The distance is XXXX.XXX
Replace XXXX.XXX with the calculated distance precise to three decimal points.
Will this be a smilier input to the same forum that wasted posted a few years ago on this site?

Here is the link...

http://www.cplusplus.com/forum/beginner/16021/


I would love the help.
Is it hard?
sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-2));
For 3D:
sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
Last edited on
sqrt((pow((x1-x2),2) + pow((y1-y2),2)))

Little cleaner
Last edited on
Topic archived. No new replies allowed.