#include<stdio.h>
#include<stdlib.h>
int main()
{
int x1; //variable to hold the x-coordinate of the first point
int x2; //variable to hold the x-coordinate of the second point
int y1; //variable to hold the y-coordinate of the first point
int y2; //variable to hold the y-coordinate of the second point
float short_distance; //variable to hold the shortest distance
int rectil; //variable to hold the rectilinear distance
printf("Enter the first point: ");
scanf("%d", &x1);
scanf("%d", &y1);
printf("\nEnter the second point: ");
scanf("%d", &x2);
scanf("%d", &y2);
short_distance = sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
printf("\nShortest distance between points: %.2f\n",short_distance);
rectil = abs(x1-y1) + abs(x2-y2);
printf("Rectilinear distance between points: %d\n", rectil);
return(0);
}
Edited by rvalkass, 05 September 2010 - 03:11 PM.














