As homework we were assigned to enter the following code to calculate the distance between two points on the x and y plane. The program should ask the user to enter two points then should calculate the distance between two points and print the distance on the screen.
My program will compile correctly but when attempting to run the actual program it doesnt do anything and some how completely skips over my main function...
Any help or corrections will be greatly appriciated!!!!
Thanks
Joe
Code:
#include <stdio.h>
#include <math.h>
struct point
{
float x;
float y;
};
void enter_a_point ( struct point pc );
float distance (struct point p1, struct point p2);
int main (void)
{
struct point pt1, pt2 ;
enter_a_point( pt1 ); //get x & y values for pt1
enter_a_point( pt2 ); //get x & y values for pt2
distance ( pt1, pt2);
printf( "Distance between the points = %.2f\n", distance(pt1, pt2) );
return 0;
}
void enter_a_point ( struct point pc )
{
printf( " Enter X value for point\n");
scanf( "%f",&pc.x );
printf( " Enter Y value for point\n");
scanf( "%f",&pc.y);
}
float distance (struct point p1, struct point p2)
{
float d;
d = sqrtf( powf((p2.x-p1.x),2)+ pow((p2.y-p1.y),2) );
return d;
}