TO CHECK WHETHER THE 3 GIVEN COORDINATES FALL ON ONE STRAIGHT LINE:
include<stdio.h>
int main()
{
float m,n,x1,x2,x3,y1,y2,y3;
printf("enter the coordinates x1,y1 = ");
scanf("%f%f",&x1,&y1);
printf("\nenter the coordinates x2,y2 = ");
scanf("%f%f",&x2,&y2);
printf("\nenter the coordinates x3,y3 = ");
scanf("%f%f",&x3,&y3);
m=(y2-y1)/(x2-x1);
n=(y3-y2)/(x3-x2);
if(m==n)
{
printf("lies on same straight line");
}
else
{
printf("not lies on same straight line");
}
return 0;
}
OUTPUT :
enter the coordinates x1,y1 = 2
3
enter the coordinates x2,y2 = 4
5
enter the coordinates x3,y3 = 6
7
lies on same straight line
Comments
Post a Comment