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

The following is the formula to calculate the distance between two points, P_1(x

ID: 3832062 • Letter: T

Question

The following is the formula to calculate the distance between two points, P_1(x_1, y_1, Z_1) and P2(x_2, Y_2, Z_2), rectangular coordinates in the Euclidian 3-D space: distance = squareroot ((x+l = x_2)**2 + (yl = y2)**2 + (zl = z2)**2) a) Since any of the differences (subtractions) can yield a negative result, should you check for that possibility in your program, so that there is not a run-time error at using the intrinsic function squareroot ? Yes/No, Why? ______________ b) Which data type(s) would be appropriate to hold the values? Why? _______________ c) What data type(s) would definitively be inappropriate? Why? __________________ d) Could you avoid enclosing the subtractions in parenthesis (ellipsis -) ? If so, how? ________________ e) Assuming that pi and p2 are two rank-1 three-dimensional arrays that hold the coordinates of the points, where the first clement in each has the x-coordinate, the second clement has the y-coordinate, and the third clement has the z-coordinate, how would the formula have to be modified in order to use the two arrays, instead of 'disconnected' variables? ________________

Explanation / Answer

A) Subtraction lead to the negative result so we need to handle this in our program otherwise it will lead to run time error whwn we do square root of negative value.

B) Float is appropriate data type which is used with square root function because square root lead to decimal point value and float is appropriate data type for decimal value.

C) Int is not appropriate data type which is used with square root function because square root lead to decimal values and decimal value got turncated in int data type.

D) We can avoid enclosing the substractions in parenthesis because while solving the equation BODMAS is used and paranthesis first comes first. If we avoid parenthesis then it leads to wrong result.