Question
Define a coordinate struct as follows: struct coordinate { double x; double y; }; Write a function that takes in an array of struct coordinate
struct coordinate {
double x;
double y;
};
Write a function that takes in an array of struct coordinate and an integer which specifies the length of the array, and returns the distance of the struct coordinate that is closest to the origin. (For example, if the array stored the points (2, 3), (5, 9), (-2, 5), and (2,1), your function should return approximately sqrt(5) since that is the distance between (2,1) and the origin.) Please DO NOT READ IN ANY INFORMATION FROM THE USER in writing this function. The prototype is given for you below. (Assume math.h is included already.)
double closestDistance(struct coordinate points[],int length);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started