Problem statement
Write a c Program to check whether three points are collinear or not
and finding the area enclosed by them
#include<stdio.h>
#include<math.h>
int main()
{
int x1,x2,x3,y1,y2,y3;
float a;
printf("enter three points resp. ");
scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
a=0.5*((x1-x2)*(y1-y3)-(x1-x3)*(y1-y2));/*evaluating area*/
// if area is 0 then points are collinear
if(a==0)
printf("points are collinear");/*collinear points*/
else
{
printf("\npoints are non-collinear\n");/*non-collinear points*/
printf("area=%0.1f",a);/*area of non-collinear points*/
}
return(0);
}
Write a c Program to check whether three points are collinear or not
and finding the area enclosed by them
#include<stdio.h>
#include<math.h>
int main()
{
int x1,x2,x3,y1,y2,y3;
float a;
printf("enter three points resp. ");
scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
a=0.5*((x1-x2)*(y1-y3)-(x1-x3)*(y1-y2));/*evaluating area*/
// if area is 0 then points are collinear
if(a==0)
printf("points are collinear");/*collinear points*/
else
{
printf("\npoints are non-collinear\n");/*non-collinear points*/
printf("area=%0.1f",a);/*area of non-collinear points*/
}
return(0);
}
No comments:
Post a Comment