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

#######I KEEP HAVING PEOPLE ANSWER WITHOUT READING THIS###### Answer has been gi

ID: 3858718 • Letter: #

Question

#######I KEEP HAVING PEOPLE ANSWER WITHOUT READING THIS######

Answer has been given as C.) !!!! I need to understand how this was derived as the answer

If you are 100% sure that it isn't a correct answer and that the answer key is wrong I need to know why....

Sorry, but I keep losing questions because people are not reading this
.

.

.

.

.

.

.

.

.

(READ ABOVE)

.

.

The following structures are designed to store information about objects in a Cartesian coordinate system 9. struct point fint x, y): struct rectangle sint upper left x, upper left_y, lower_right x, lower_right y;) A point structure stores the x and y coordinates of a point. A rectangle structure stores the coordinates of the upper left and lower right corners of a rectangle. Which of the following functions will correctly determine whether a point p lies within rectangle r, return 1(true) or O(false)? a) int is-inside (struct point p, struct rectangle r){ return p.x > r. upper-left-y r.upper-left-x && p.x r.upper-left-y r. lower-right-x && p.x = r.upper-left-X && p.x = r. upper-left-x && r . upper-left-y; } && r. lower-right-X r. lower-right-y p.x = && p-Y

Explanation / Answer

c)

int is_inside(struct point p,struct rectangle r)

{

return p.x >= r.upper_left_x && p.x <= r.lower_right_x && p.y >= r.lower_right_y && p.y <= r.upper_left_y;

}

Explaination:

The upper left and lower right coordinates of the rectangle are given as below:

(upper_left_x, upper_left_y)

*

p(x,y)

-------->x *(lower_right_x,lower_right_y)

so , a point p to be inside the rectangle , x should be between upper_left_x and lower_right_x

and y should be between lower_right_y and upper_left_y

These conditions are checked in the function is_inside and the correct answer is C

p(x,y)