Question: C code program help. I am trying to find the distance between two points. This is what I have so far. It does run, it

C code program help.

I am trying to find the distance between two points. This is what I have so far. It does run, it does ask for numbers. But it doesn't calculate. It just comes out "The distance is: 0.00" I have tried several combinations of putting different data types in both main.c and the rest of it.

Any help or ideas would be helpful. Thank you.

(There are other questions that were in the code but I have deleted it before posting. So there might be some random code still left in here. But I tried really hard to comment out everything but the part I was working on. )

#define _CRT_SECURE_NO_WARNINGS #include #include #include

int main(void) { //Distance Between Two Points double numberx1 = 0.0, numbery1 = 0.0, numberx2 = 0.0, numbery2 = 0.0; double distance = 0.0; double square1 = 0.0; numberx1 = get_numberx1(); numbery1 = get_numbery1(); numberx2 = get_numberx2(); numbery2 = get_numbery2(); square1 = get_square1(); distance = calculate_distance(square1); display_distance(distance); }

//Distance Between Two Points Materials int get_numberx1(void) { double numberx1 = 0.0; printf("Please enter the x-coordinate from the first set of coordinate pairs: "); scanf("%lf", &numberx1); return numberx1; } int get_numbery1(void) { double numbery1 = 0.0; printf("Please enter the y-coordinate from the first set of coordinate pairs: "); scanf("%lf", &numbery1); return numbery1; } int get_numberx2(void) { double numberx2 = 0.0; printf("Please enter the x-coordinate from the second set of coordinate pairs: "); scanf("%lf", &numberx2); return numberx2; } int get_numbery2(void) { double numbery2 = 0.0; printf("Please enter the y-coordinate from the second set of coordinate pairs: "); scanf("%lf", &numbery2); return numbery2; }

int get_square1(numberx1, numberx2, numbery1, numbery2) { double square1 = 0.0; square1 = (double)((pow((numberx1 - numberx2), 2)) + (pow((numbery1 - numbery2), 2))); return square1; } int calculate_distance(square1) { double distance = 0.0; distance = (sqrt(square1)); return distance; } display_distance(distance) { printf("The distance is: %.2lf ", distance); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!