Write a program to calculate the distance between 2 points (x1,y1) and
(x2,y2)
Distance = square root of(x2 -x1)2 + (y2-y1)2
I'm import java
Answers
Answered by
1
Answer:
Explanation:
int main() {
float x1, y1, x2, y2, gdistance;
printf("Input x1: ");
scanf("%f", &x1);
printf("Input y1: ");
scanf("%f", &y1);
printf("Input x2: ");
scanf("%f", &x2);
printf("Input y2: ");
scanf("%f", &y2);
gdistance = ((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1));
printf("Distance between the said points: %.4f", sqrt(gdistance));
printf("\n");
return 0;
}
Similar questions