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

Syntax of C-language

Variable & Datatype for C-programming

Language Translator of C-language

Errors in C-language

Addition of two numbers in c language

Introduction of C-language.

Linear search in C-language

Binary searching in C-language

Program to reverse one array into other array in C-language