Write your question here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <stdio.h>
#include <math.h>
int main()
{
float x1;
float y1;
float x2;
float y2;
float Distance;
x1 = 7;
y1 = 12;
x2 = 3;
y2 = 9;
Distance = sqrt(pow((x1-x2),2)+pow((y1-y2),2));
printf("The distance between points (7,12) and (3,9) is f%", Distance);
return 0;
}
|
I have to have this output
The distance between points (7,12) and (3,9) is 5.000000
This is what I got
The distance between points (7,12) and (3,9) is f
*I just realized this program made no sense. Not for the X and Y anyway. The formula works. I just can't get the right output.
Here is my exact problem:
Write, compile, and execute a C program that calculates the distance between two points whose coordinates are (7,12) and (3,9). Use the fact that the distance between two points having coordinates (x1,y1) and (x2,y2) is distance = sqrt([x1-x2]^2 + [y1-y2]^2).