80.9k views
2 votes
Enter the following code to calculate the distance between two points on the x, y plane. The program asks a user to enter 2 points, then calculates the distance between the 2 points and prints out the distance on the screen. You need to replace any "?" with the appropriate code. #include #include - Since you are using the math library, you'll need to include the -Im option when compiling, for example: gec extra4.c-Im-o extra4 struct point float x; float y: }; float distance (struct point, struct point); void enter_a_point ( struct point *); int main (void) struct point pti, pt2; enter_a_point(?); //get x 6 y values for pti enter_a_point(?): //get x & y values for pt2 printf( "Distance between the points=4.2f\\", distance(?, ?) ); return 0; Distance Formula float distance (struct point p1, struct point p2) 4 = (x - x) + (y - y) return sart pow( ?, 2) - powl ?, 2)); < void enter_a_point ( struct point p) printf("\\Enter an X coordinate: "); scanf("f", ?); printf("\\Enter a y coordinate: "); scanf("%f", ?);

User Kokos
by
5.2k points

1 Answer

7 votes

Answer:

Step-by-step explanation:

Ok, I don't understand anything at the end because it's utter gibberish.

What you can do, based on the question, is ask user input for the two x and two y coordinates, then use the distance formula. The distance is
√((x_1-x_2)^2+(y_1-y_2)^2) . Find a way to insert that using the math library.

Hope that helped,

-FruDe

User Pkhlop
by
5.3k points