/* A C program to calculate the distance between two points */ /* */ /* compile this with: */ /* gcc -lm -o dist dist.c */ #include #include int main (void) { double x1=2.0, y1=4.0; double x2=5.0, y2=8.0; double dx, dy; double d, d_sq; dx = x2 - x1; dy = y2 - y1; d_sq = dx*dx + dy*dy; d = sqrt(d_sq); printf("%f\n", d); return 0; }