I need help with using the distance formual in my program. I dont know the proper way to use the square root function. I have figured out how too properly input the part of the distance formula that is inside the square root but i do not know how to take the square root of it. Here is my program:
#include <stdio.h>
int main (void)
{
/* X,Y = Coordinates of 1st Plane and A,B= Coordinates of 2nd
Plane*/
int integer; int X,Y,A,B;
float distance;
printf( "Enter the x and y coordinates of the first plane.\n");
scanf( "%d %d", &X, &Y);
printf( "Enter the x and y coordinates of the second plane.\n");
scanf( "%d %d", &A, &B);
distance= ((A-X)*(A-X))+((B-Y)*(B-Y));
printf("The distance is %.2f\n", distance);
return 0;
}
Do i float for distance since i have to include the sqaure root or do i use a double? Will some one please show me the correct way to execute the distance formula? I woule really appreciate it!!!!![]()



LinkBack URL
About LinkBacks



