Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Thank you for trying to help! 1. Define and typedef a struct Point that contains

ID: 3872764 • Letter: T

Question

Thank you for trying to help!

1.    Define and typedef a struct Point that contains two double variables m and n. An instance of Point represents a point .

2.    Define and typedef a struct Circle that contains a double variable radius and a Point variable center.

3.    Define and typedef a struct Square that contains a Point variable origin that is the top left corner of the rectangle, and two double variables width and height(they are equal).

4.    Create a function distanceofPoints() that takes pointers to two Point structs, and computes the distance between them. The distance between two points is the square root of the square of the m distances plus the square of the n distances for the two points. The function returns a double.

5.    Create a function intersectsCircles() that takes pointers two Circle structs circle1 and circle2and returns true if the two Circles intersect and false otherwise. Two Circles intersect if the distance between their centers is less than the sum of the two radius.

6.    Create a function getBox() that takes pointer to an input parameter Circle, circle and a pointer to a Square result parameter Box. The function and sets the fields of Square to the bounding box that encloses the circle. The function returns a pointer to the Square result parameter.

7.    Create a main program that tests the intersectsCircles() function :

a) circle1 at 0,0 radius 10, and circle2 at 20, 0, radius 10: do not intersect

b) circle1 at 0,0 radius 10, and circle4 at 19,0, radius 10: intersect

In the main , test the getBox() function by declaring an uninitialized Square Box and calling the getBox() function for circle1, circle2, circle3, and circle4. Print the origin, width, and height of the Box for each circle.

Please using C language to solve this problem and give some explanations if possible. Thank you very much for your help!

Explanation / Answer

1)
Ans)
The answer is given below as you asked to Define and typedef a struct Point that contains two double variables m and n. An instance of Point represents a point.

typedef struct
{
double m;
double n;
} Point;

2)

Ans) The answer is given below as you asked to Define and typedef a struct Circle that contains a double variable radius and a Point variable center

typedef struct
{
Point center;
double radius;
} Circle;

3)

Ans) The answer is given below as you asked to Define and typedef a struct Square that contains a Point variable origin that is the top left corner of the rectangle, and two double variables width and height(they are equal).

typedef struct
{
double width;
double height;
} Square;

Hope This Helps, if you have any doubts Please comment i will get back to you, thank you and please thumbs up

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote