move to repo.or.cz
[letusc.git] / ch2 / exercises1 / ex10.c
blob2f4d0c901abede7c909a132708504ab08f5af844
1 /* to check whether all the three points lie on a straight line */
3 #include<stdio.h>
5 int main()
7 int x1,y1,x2,y2,x3,y3;
8 float area;
9 printf("Enter X1,Y1:");
10 scanf("%d %d",&x1,&y1);
12 printf("Enter X2,Y2:");
13 scanf("%d %d",&x2,&y2);
15 printf("Enter X3,Y3:");
16 scanf("%d %d",&x3,&y3);
18 /*compute the area formed by these three points. if
19 it is zero , then they all lie on a same line i.e they don form a triangle */
20 area = (1/2)*((x1*(y2-y3))+(x2*(y3-y1))+(x3*(y1-y2)));
22 if(area == 0)
23 printf("They lie on a straight line\n");
24 else
25 printf("They dont lie on a straight line\n");
27 printf("Press any key to exit\n");
28 getch();
29 return 0;