I have to do this problem. I\'m pretty confident with part A I justdon\'t know h
ID: 3618431 • Letter: I
Question
I have to do this problem. I'm pretty confident with part A I justdon't know how to put distance() into main() forpart B. Any help is appreciated for either part. Thankyou.A) Write a function named distance() that accepts therectangular coordinates of two points x1,y1 and x2,y2 and calculates and returns the distance between the twopoints.
B) Include the function written for A) in a working C program. Makesure your function is called from main() and correctlyreturns a value to main(). Have main() displaythe value returned and test the function by passing various data toit and verifying the returned value. In particular make sure yourfunction returns a value of 0 when both points are thesame.
Explanation / Answer
please rate - thanks #include #include #include double distance(); int main() { double dist; dist=distance(); printf("distance between them: %f ",dist); getch(); return 0; } double distance() {double x1,y1,x2,y2; printf("Enter point 1(x1 y1): "); scanf("%lf",&x1); scanf("%lf",&y1); printf("Enter point 2 (x2 y2): "); scanf("%lf",&x2); scanf("%lf",&y2); printf("point 1: ( %f,%f) ",x1,y1); printf("point 2: ( %f,%f) ",x2,y2); return sqrt(pow((x2-x1),2)+pow((y2-y1),2)); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.