I tried to calculate distance between 2 points, A, B. When I run the terminal window it give me a false number. Can anyone help me to change some value, or stuct or many tips.
Example: in A : -50 -50 in B : 50 50 distance is 141.42
#include<stdio.h>
#include<conio.h>
#include<math.h>
typedef struct{
double a;
double b;
double c;
double d;
}location;
double dist(location w,location x, location y,location z)
{
double l;
l=sqrt(pow((y.c-w.a),2)+pow((z.d-x.b),2));
return(l);
}
void main()
{
location h;
location i;
location j;
location k;
printf("Enter 1st point(A)\n");
scanf("%lf %lf",&h.a,&i.b);
printf("Enter 2nd point(B)\n");
scanf("%1f %1f",&j.c,&k.d);
double data;
data = dist(h,i,j,k);
printf("%.2lf",data);
}