InterviewSolution
Saved Bookmarks
| 1. |
Write a C program that accepts coordinates of two-dimensional points A and B and prints out (using two decimal places) the distance between A and B. It also prints out thecoordinates (using two decimal places) of the midpoint of A and B. |
| Answer» KNOW ProgramMain MenuC Program to Find the DISTANCE Between Two PointsC Program, C Programming / Leave a CommentProgram description:- Write a C program to find the distance between two given points.The distance formula is derived from the Pythagorean theorem. To find the distance between two points (x1, y1) and (x2, y2), all that you need to do is use the coordinates of these ORDERED pairs and apply the formula.Distance FormulaAssume we have two points M and N, with coordinates (x1, y1) and (x2, y2) respectively. Their distance can be represented as MN and it can be calculated as given below formula, The first POINT (M):- (x1, y1)Second point (N):- (x2, y2)Distance (MN):- √((x2-x1)2 + (y2-y1)2)Example:-M = (4, 8)N = (12, 14)Then distance between M and N is, MN = √((12-4)2 + (14-8)2) = √(64 + 36) = √(100) = 10 | |