2.10: Math functionsIntroduction to Computer Science I with Laboratory home >
2.10.1: Coordinate geometry.
Determine the distance between point \((x_1, y_1)\) and point \((x_2, y_2)\), and assign the result to pointsDistance. The calcula
Distance = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}
Ex: For points \((1.0, 2.0)\) and \((1.0, 5.0)\), pointsDistance is 3.0.
1 #include <iostream>
2 #include <cmath>
3 using namespace std;
4
5 int main() {
6
double x1;
7
double y1;
8
double x2;
9
double y2;
10
double xDist;
11
double yDist;
12
double pointsDistance;
13
14 xDist = 0.0;
15 yDist = 0.0;
16 pointsDistance = 0.0;
17
18 cin >> x1;
19 cin >> y1;
20 cin >> x2;