Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Page 1 of 1
#include<stdio.h>
#include<math.h>
struct point
{
int x;
int y;
float area;
}p1,p2,p3,p4;
int addpoint(int, int, int, int);
float dist(int, int, int, int);
float ptinrect(int, int, float);
main()
{
int g,h;
float area1;
printf("Enter the 2D co-ordinates of point 1 : ");
scanf("%d %d",&p1.x,&p1.y);
printf("\nEnter the 2D co-ordinates of point 2 : ");
scanf("%d %d",&p2.x,&p2.y);
addpoint(p1.x,p2.x,p1.y,p2.y);
printf("\n The area of the rectangle is calculated using 3 points \n");
printf("Enter the 2D co-ordinates of point 3 : ");
scanf("%d %d",&p3.x,&p3.y);
g=dist(p1.x,p1.y,p2.x,p2.y);
h=dist(p2.x,p2.y,p3.x,p3.y);
area1=g*h;
printf("\nArea of the 3 points (%d,%d)(%d,%d) and (%d,%d) is %f",p1.x,p1.y,p2.x,p2.y,p3.x,p3.y,area1);
printf("\n Enter the co-ordinate to be checked whether it lies in the area or not : ");
scanf("%d %d",&p4.x,&p4.y);
ptinrect(p4.x,p4.y,area1);
}
int addpoint(int p, int q, int r, int s)
{
int t,u;
t=p+q;
u=r+s;
printf("\nThe added points are %d and %d \n",t,u);
return 0;
}