Showing posts with label Program to Calculate the Distance between two Co-Ordinates. Show all posts
Showing posts with label Program to Calculate the Distance between two Co-Ordinates. Show all posts

Program to Calculate the Distance between two Co-Ordinates

//Program to Calculate the Distance between two Co-Ordinates
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
  float x1,x2,y1,y2,d;
  clrscr();
  printf("Enter the co-ordinates of the two Points\n");
  scanf("%f%f%f%f",&x1,&x2,&y1,&y2);
  d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  printf("The Distance between two Points is = %f",d);
 
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.