Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 41: Write a C++ program to calculate the distance between two points.

#include<iostream>
#include<math.h>
using namespace std;

int main()
{
	int x1,x2,y1,y2;
	double dist;
	cout<<"\nenter the co-ordinates of point 1 : ";
	cin>>x1>>x2;
	cout<<"\nenter the co-ordinates of point 2 : ";
	cin>>y1>>y2;

	dist=sqrt(pow(x1-y1,2)+pow(x2-y2,2));
	cout<<"\ndistance between given two points : "<<dist;
	return 0;
}



If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.