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

E zyBooks catalog 6.21 HW11-01: Distance between two points Given two points (x1

ID: 3723144 • Letter: E

Question

E zyBooks catalog 6.21 HW11-01: Distance between two points Given two points (x1. y1) and (2 y2). the distance between this points is defined as the square root of (2-x1)*2+(y2-y1l)y2 Write function distance(x1, y1, x2. y2) that returns the distance between the given points. The main0 function is written for you, your job write the distance function. Start by reviewing the code for mai that the main0 program inputs two points (k1, y'l) and (k2, y2),cals distance to compute the distance, and then outputs this reslt in.cpp' which is visible in the editor pane note that this code is read-only (you cannot modify Above the editor pane youll see the text Current file main cpp with a little drop-down arrow to the right Click the drop-down ands functions.cpp. Then, to avoid a bug in some web browsers, please immediately click the link 'Load default template..: You only n 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 bmit for grading. You have unlimited submissions When you are ready to submit for testing, switch to Submit mode and su 0/100 ACTIVITY 621.1: HW11-01. Distance between two points Load default template Current file: functions.cpp 1 /.functions.cpp

Explanation / Answer

#include <iostream>

#include <string>

#include <cmath>

using namespace std;

double distance(int x1,int y1, int x2, int y2) {

double dist= sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));

return dist;

}