Code:
#include <stdio.h>
struct point {
int x, y;
};
struct rectangle {
struct point upper_left, lower_right;
} ;
void area_of_r(int x, int y);
void center_of_r(int x, int y);
void move_r(int x, int y);
void point_on_r(int x, int y);
int main()
{
int area;
struct rectangle r;
/* get value of x and y of point r on graph */
printf("input upper left (x,y) x value of point r : ");
scanf("%d",&r.upper_left.x);
printf("\ninput upper left (x,y) y value of point r : ");
scanf("%d",&r.upper_left.y);
printf("\npoint r coordinates are : (%d,%d)",r.upper_left.x, r.upper_left.y);
printf("input lower_right (x,y) x value of point r : ");
scanf("%d",&r.lower_right.x);
printf("\ninput lower_right (x,y) y value of point r : ");
scanf("%d",&r.lower_right.y);
printf("\npoint r coordinates are : (%d,%d)",r.lower_right.x, r.lower_right.y);
area = area_of_r(r);
return 0;
}
int area_of_r(struct rectangle r)
{
int area = (r.lower_right.x - r.upper_left.x) * (r.lower_right.y - r.upper_left.y);
return area;
}
Now the upper left (x,y) and lower right (x,y) input has to make sense. Try something like (2,2) and (6,8).