Created
March 9, 2017 15:22
-
-
Save PanchoBarrancas/cdd91a03f1f0d3b479e74d41854a719b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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