C program to calculate the distance between two points - My CS Tutorial - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Tuesday, January 7, 2020

C program to calculate the distance between two points - My CS Tutorial

C program to find or print the distance between two points.
In this tutorial we will learn how to write a c program to print the distance between two points.
We will enter the value of (x1,y1) and (x2,y2).




C program code


#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
 int x1,x2,y1,y2;
 clrscr();
 double distance;
 printf("\n ENTER THE VALUE OF X1: \n ");
 scanf("%d",&x1);
 printf("\n ENTER THE VALUE OF Y1:\n ");
 scanf("%d",&y1);
 printf("\n ENTER THE VALUE OF X2:\n ");
 scanf("%d",&x2);
 printf("\n ENTER THE VALUE OF Y2:\n ");
 scanf("%d",&y2);
 distance=sqrt((pow((x2-x1),2))+(pow((y2-y1),2)));
 printf("\n DISTANCE BETWEEN TWO POINTS = %lf\n ",distance);
 getch();
}


OUTPUT:





In this output we can see,this program find the distance between two points.
In the first we will enter the value of (x1,y1)and (x2,y2).
After this it is print the distance between two points.


Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com

Created by-- HARSH CHAUHAN

No comments:

Post a Comment