# C Program to Implement Distance Calculation using Distance Formula

This C program finds the distace between two points using distance formula

While compiling use -lm [linking math to incorporate math functions] eg: cc prog.c -lm

```
#include<stdio.h>
#include<math.h>
main()
{
double x1,y1;
double x2,y2;
printf("Welcome to Distance Formula Finder Software n");
printf("Enter the Two points x1 and y1 n");
scanf("%lf%lf",&x1,&y1);
printf("Enter the final points x2 and y2 n");
scanf("%lf%lf",&x2,&y2);
double m=x2-x1;
double n=y2-y1;
double j=m*m;
double p=n*n;
double d=j+p;
double odist=sqrt(d);
printf("The Distance between given points are %lf meters n",odist);
}
```

OUTPUT:

Welcome to Distance Formula Finder Software

Enter the Two points x1 and y1

1

2

Enter the final points x2 and y2

4

5

The Distance between given points are 4.242641 meters

## Recent Comments