Saturday, 12 December 2015

write a program that input the x,y coordinates for two points and compute the distance between two points using formula Distance= sqrt[(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)]

#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{ float x1,y1,x2,y2,d;
cout<<"Enter coordinates (x1,y1)"<<endl;
cin>>x1>>y1;
cout<<"Enter coordinates (x2,y2)"<<endl;
cin>>x2>>y2;
d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
cout<<"distance is = "<<d;
getch();
}

No comments:

Post a Comment