Algorithm to get distance between two points?

kushon
kushon

Posted On: Apr 10, 2020

 

The algorithm to find the distance between two points is as follows.

#include <bits/stdc++.h>
Using namespace STD;
// Calculation of the distance
float distance(int x1, int y1, int x2, int y2)
 { 
  // calculating the distance 
return sqrt(pow(x2 - x1, 2) + 
pow(y2 - y1, 2) * 1.0);
 }
// Code of the Drivers
int main()
{
cout << distance(3, 4, 4, 3);
return 0;
 }

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Cyient GIS Interview Questions

    What is GIS?

    Geographic information system (GIS) is a system planned to capture, amass, maneuver, analyze, administer, and present all types of geographical data. GIS applications are tools that allow users to pro...

    Cyient GIS Interview Questions

    List some computer shortcuts?

    A computer shortcut is a set of keys which can be one or more meant to invoke a command in software or an operating system. And to increase one&rsquo;s efficiency by invoking commands with keyboard ke...

    Cyient GIS Interview Questions

    What are fossil fuels?

    Fossil fuels are a class of hydrocarbon-containing materials present inside Earth&rsquo;s outer layer that works as the source of energy. Coal, crude oil, and natural gas are the eminent fossil fuels ...