The user is supposed to enter two points (x,y) and then its supposed to calculate the distance between the two points and display it on the output screen.
I am having problems with my math down at the bottom, the complier doesnt like it. Can someone please tell me whats wrong with it? Also, if you see any other mistakes, please let me know. Thanks!
Expert Answer


#include <stdio.h>
#include <math.h>
struct point
{
float x;
float y;
};
int enter_a_point(struct point *pc);
float distance(struct point p1, struct point p2);
int main(void)
{
struct point pt1, pt2;
float dist;
enter_a_point(&pt1);
enter_a_point(&pt2);
dist = distance(pt1, pt2);
printf(“Distance between the points=%.2fn”, dist);
system(“pause”);
return 0;
}
int enter_a_point(struct point *pc)
{
printf(“Enter X value for point:n”);
scanf_s(“%f”, &pc->x);
printf(“Enter Y value for point:n”);
scanf_s(“%f”, &pc->y);
return 0;
}
float distance(struct point p1, struct point p2)
{
float d;
d = sqrt(pow((p2.x – p1.x), 2) + pow((p2.y – p1.y), 2));
return d;
}