Skip to content

Instantly share code, notes, and snippets.

@PanchoBarrancas
Created March 9, 2017 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PanchoBarrancas/cdd91a03f1f0d3b479e74d41854a719b to your computer and use it in GitHub Desktop.
Save PanchoBarrancas/cdd91a03f1f0d3b479e74d41854a719b to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cmath>
float distance (float, float, float, float);
int main ()
{
float x1 = 0, y1 = 0, x2 = 0, y2 = 0;
std::cout << "X uno, puh-leeze" << std::endl;
std::cin >> x1;
std::cout << "Y uno, puh-leeze" << std::endl;
std::cin >> y1;
std::cout << "X dos, puh-leeze" << std::endl;
std::cin >> x2;
std::cout << "Y dos, puh-leeze" << std::endl;
std::cin >> y2;
std::cout << "\nThe distance is " << distance (x1, y1, x2, y2) << std::endl;
std::cout << "\nBuh-bye" << std::endl;
}
float distance (float x1, float y1, float x2, float y2)
{
float delta_x = 0, delta_y = 0, rdistance = 0;
delta_x = x2 - x1;
delta_y = y2 - y1;
rdistance = sqrt(pow(delta_x, 2) + pow(delta_y, 2));
return rdistance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment