I am working on an assignment where I have to create a program for users to input coordinates for a rectangle.
This program is intended to be a struct within a struct.
If invalid, I have to output an error message and let user try again, indefinitely, until the user gets it right.
The program should repeatedly ask users for coordinates of a point, and the program will quit when user enters 0 and 0 for x and y respectively.
The program has to say whether the point is inside of outside the rectangle. I also need to figure out where to put the main function, and what to put in it. Please let me know how exactly to complete this program, and I need to know ASAP. The program is due TONIGHT.
Here is my code:
int is_inside (point_t* pPoint, rectangle_t* pRect)
return ((pPoint->x >= pRect->upper_left.x ) &&
(pPoint->x <= pRect->lower_right.x) &&
(pPoint->y >= pRect->upper_left.y ) &&
(pPoint->y <= pRect->lower_right.y));
point_t get_point(char* prompt)
printf("Given a rectangle with a side parallel to the x axis and a series of points on the xy plane this program will say where each point lies in relation to the rectangle. It considers a point on the boundary of the rectangle to be inside the rectangle\n");
printf ("Enter coordinates for the upper left corner\n");
printf ("X: ");
scanf ("%d", &pt.x);
printf ("Y: ");
scanf ("%d", &pt.y);
rectangle_t get_rect(char* prompt)
rect.upper_left = get_point("Upper left corner: \n");
rect.lower_right = get_point("Lower right corner: \n");