Advertisement
Sanlover

Untitled

Dec 25th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int main() {
  5. double x_1, x_2, y_1, y_2, distance;
  6.  
  7. cout << "Enter the coordinates of the first point:" << endl;
  8. cout << " X = ";
  9. cin >> x_1;
  10. cout << " Y = ";
  11. cin >> y_1;
  12. cout << endl << "Enter the coordinates of the second point:" << endl;
  13. cout << " X = ";
  14. cin >> x_2;
  15. cout << " Y = ";
  16. cin >> y_2;
  17.  
  18. distance = sqrt((x_2 - x_1) * (x_2 - x_1) + (y_2 - y_1) * (y_2 - y_1));
  19. cout << endl << "The distance between [" << x_1 << ";" << y_1 << "] and [" << x_2 << ";" << y_2 << "] is " << distance;
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement