Program to calculate distance between two points

Program to calculate distance between two points

#include<stdio.h>
#include<math.h>
int main()
{
    float x1,x2,y1,y2,D;
    printf("Enter the point x1,x2\n");
    scanf("%f%f",&x1,&x2);
    printf("Enter the value of y1,y2\n");
    scanf("%f%f",&y1,&y2);
   D=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
  printf("Distance betweent two points=%f",D);
}

OUTPUT
Enter the point x1,x2
4
2
Enter the value of y1,y2
5
1
Distance between two points=4.472136

this program is best example  of combination of sqrt and pow function
In this program we use these function for calculating distance between two points.

If you like this program then you can share it and for any issues you can direct contact with me from Home Page.

For regular updates you can also follow my site.





Comments

Popular posts

Creative pattern of butterfly in C-language

Program to show present time and date in C-language

Introduction of C-language.

Program to cheque enter number is a perfect number or not using if else in C-language

Program to cheque four digits number is palindrome or not in C-language

Program to print the cube of a number in c-language

Simple Hello world program in c- language