#include<stdio.h>
#include<math.h>
int
main
()
{
int x1,
x2, y1, y2;
float r;
printf( "Enter Point (x1,y1): " );
scanf( "%d"
,&x1);
scanf( "%d"
,&y1);
printf( "\nEnter Point (x2,y2):
"
);
scanf( "%d%d"
,&x2,&y2);
r = sqrt(pow((y2-y1),2)
+ pow((x2-x1),2));
printf( "\nDistance= %f"
,r);
return 0;
}
|
Write a c program to calculate the distance between two points using formula √ (( y2− y1)² +( x2− x1)²)
Subscribe to:
Post Comments (Atom)
With this code , can I calculate the distance between two district ??
ReplyDeleteThis program finds only straight distance between two points. If you need straight distance between two districts and you have known points for them, then you can gain the result from this program.
DeleteNice one
ReplyDeletethanks
ReplyDeleteex1setb1.c:11:2: error: too few arguments to function ‘pow’
ReplyDeleteex1setb1.c:11:2: error: too few arguments to function ‘pow’
ex1setb1.c:11:8: error: subscripted value is neither array nor pointer
what to do sir??
Please write your code... So that we can judge if you have any typo.
Deletefabolous.
ReplyDeletethanks brother
ReplyDeletethanks this is good blog. entfernungsrechner
ReplyDelete