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

Assume each vertex is a pair of integer coordinates. A triangle with vertices A,

ID: 3635512 • Letter: A

Question

Assume each vertex is a pair of integer coordinates. A triangle with vertices A, B, and C is a right triangle if d(A,B)2=d(B,C)2+d(A,C)2, where d(P1,P2) represents the distance between two points, P1 and P2. A, B, and C may be given in any order. Write a program and create a user defined function vertices that takes two points (xi,yi) and (x^y?) and returns the distance between them. Use the formula: The program will continue to process any number of triangles until a unique value is entered by the user to stop processing. Note: Using Loops and user defined functions is a must.

Explanation / Answer

#include #include double calculate_distance (double x1,double y1,double x2 ,double y2) { double distance; double distance_x = x1-x2; double distance_y = y1- y2; distance = sqrt( (distance_x * distance_x) + (distance_y * distance_y)); return distance; } int main () { double x1; double x2; double y1; double y2; printf ("Let me help you find the distance between two points (x1,y1) and (x2, y2)."); printf (" Enter coordinate for x1:"); scanf ("%f", &x1); printf (" Enter coordinate for y1:"); scanf ("%f", &y1); printf (" Enter coordinate for x2:"); scanf ("%f", &x2); printf (" Enter coordinate for y2:"); scanf ("%f", &y2); printf ("The distance between (%f,%f) and (%f,%f) is %.2f ", x1,y1,x2,y2, calculate_distance(x1,y1,x2,y2)); return 0; }
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