Page

Sunday 31 March 2019

program for three points on straight line||luv yadav||


/*given three points (x1,y1), (x2,y2)and (x3,y3), write a program
 to chek if all the three points fall on one straight line*/
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int x1,x2,x3,y1,y2,y3,t;
printf("x1:");
scanf("%d",&x1);
printf("x2:");
scanf("%d",&x2);
printf("x3:");
scanf("%d",&x3);
printf("y1:");
scanf("%d",&y1);
printf("y2:");
scanf("%d",&y2);
printf("y3:");
scanf("%d",&y3);
t=(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2));
if(t==0)
{
printf("this points present om straight line:");
}
else
{
printf("this point does not lie on straight line:");
}
getch();
return(0);
}




by luv yadav

No comments:

Post a Comment