PROGRAM TO IMPLEMENTING DISTANCE FORMULA || BigFootCODE
![]() |
Distance formula |
Q) Write a program to read coordinates of two points and calculates distance between two points using formula d^2=(x1-x2)^2 + (y1-y2)^2)
sol)
#include<iostream.h>< #include<math.h> | ||
int main() | ||
{ double distance,x1,x2,y1,y2; | ||
cout<<"enter the coordinates of point 1 :"; | ||
cin>>x1>>y1; | ||
cout<<"enter the coordinates of point 2 :"; | ||
cin>>x2>>y2; | ||
distance=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); | ||
cout<<"thedistance between("<<x1<<","<<y1<<")and("<<x2<<","<<y2<<") is : "<<distance<<endl; | ||
return 0; | ||
}
|
0 Comments
if you have any doubt let me know in comment