Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given two points (x1, y1) and (x2, y2), the distance between this points is defi

ID: 3723583 • Letter: G

Question

Given two points (x1, y1) and (x2, y2), the distance between this points is defined as the square root of (x2-x1)*2+ (y2-y1)"2. Writea function distance(x1, y1, x2, y2) that returns the distance between the given points. The main function is written for you; your job is to write the distance function. Start by reviewing the code for "main.cpp" which is visible in the editor pane note that this code is read-only (you cannot modify it). Notice that the main0 program inputs two points (x1, y1) and (x2, y2), calls distance to compute the distance, and then outputs this result. Above the editor pane you'll see the text·Current file: main.cpp", with a little drop-down arrow to the right. Click the drop-down and select functions.cpp. Then, to avoid a bug in some web browsers, please immediately click the link "Load default template.... You only need to do this once, the first time you view the file. Implement the function. To test your work in Develop mode, supply two points in the following format: 0, 0 10,10 Each point is on a line by itself, with no spaces. In this case the output should be Distance: 14.1421 When you are ready to submit for testing, switch to Submit mode and submit for grading. You have unlimited submissions. LAB ACTIVITY 6.21.1: HW11-01: Distance between two points 0/100 Current file: functions.cpp Load default template... 1 functions.cpp 3 #include 4 #include 5 #include 7 using namespace std; 9 double distanceintx int yl, int x2, int y2) 10 11 12 13 return 0.0 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the Develop mode Submit mode

Explanation / Answer

#include <iostream>
#include <string>

#include <cmath>
using namespace std;
double distance(int x1, int y1, int x2, int y2) {
return sqrt(pow(x2-x1, 2) + pow(y2-y1, 2));
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote