Ticker

6/recent/ticker-posts

Header Ads Widget

PROGRAM TO IMPLEMENTING DISTANCE FORMULA

PROGRAM TO IMPLEMENTING DISTANCE FORMULA || BigFootCODE



PROGRAM TO IMPLEMENTING DISTANCE FORMULA , bigfootcode , blogger , blog
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;
}






Post a Comment

0 Comments