Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Get detailed and accurate answers to your questions from a community of experts on our comprehensive Q&A platform. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.
Sagot :
Answer:
#include <stdio.h>
#include <math.h>
int main(){
float x1,x2,y1,y2,distance;
printf("x1: "); scanf("%f", &x1);
printf("y1: "); scanf("%f", &y1);
printf("x2: "); scanf("%f", &x2);
printf("y2: "); scanf("%f", &y2);
distance = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
printf("Distance: %f", distance);
return 0;
}
Explanation:
This line declares all required variable (i.e. the coordinates and the distance)
float x1,x2,y1,y2,distance;
The next four line prompt and get input for the coordinates
printf("x1: "); scanf("%f", &x1);
printf("y1: "); scanf("%f", &y1);
printf("x2: "); scanf("%f", &x2);
printf("y2: "); scanf("%f", &y2);
This calculates the distance
distance = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
This prints the calculated distance
printf("Distance: %f", distance);
See attachment for sample runs
We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Thank you for visiting Westonci.ca. Stay informed by coming back for more detailed answers.