// C EXAMPLE: Find 3D distance between points // Compile with: gcc -lm -o Distance3d Distance3d.c // Execute with: ./Distance3d #include #include int main () { float x1,x2,y1,y2,z1,z2,dist; printf ("Let me help you find the distance between two points (x1,y1) and (x2, y2)."); printf ("\n\nEnter coordinate for x1:"); scanf ("%f", &x1); printf ("\nEnter coordinate for y1:"); scanf ("%f", &y1); printf ("\nEnter coordinate for z1:"); scanf ("%f", &z1); printf ("\nEnter coordinate for x2:"); scanf ("%f", &x2); printf ("\nEnter coordinate for y2:"); scanf ("%f", &y2); printf ("\nEnter coordinate for y2:"); scanf ("%f", &z2); dist= sqrt( (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)); printf ("The distance between (%f,%f,%f) and (%f,%f,%f) is %.2f\n\n", x1,y1,z1,x2,y2,z2,dist); return 0; }