Carlo Marino
0
Q:

Input the coördinates and calculate the distance between them c#

static void Main() {
  double d, x1, x2, y1, y2;
 
  Console.Write("Enter coordinates for point A: ");
  x1 = Double.Parse(Console.ReadLine());
  y1 = Double.Parse(Console.ReadLine());
 
  Console.Write("Enter coordinates for point B: ");
  x2 = Double.Parse(Console.ReadLine());
  y2 = Double.Parse(Console.ReadLine());
   
  d = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
     
  Console.Write("Distance between points: " + d);
  Console.ReadKey();
}
0

New to Communities?

Join the community