Computer Science, asked by starmogh1011, 1 year ago

Write a C program to find distance between two points.

Answers

Answered by Shanayasharma2907
1

#include <stdio.h>

#include <math.h>

int main()  

{

float px1, py1, px2, py2, dist;

px1=25;

   py1=15;

px2=35;

py2= 10;

dist = ((px2-px1)*(px2-px1))+((py2-py1)*(py2-py1));

printf("Distance between the given two points is: %.4f", sqrt(dist));

printf("\n");

return 0;

                }

Explanation:  

px1, py1 are the co-ordinates of Point 1 and px2, py2 are co-ordinates of Point 2.  

Dist variable is squared to get the distance between these two points.


Similar questions