/* A program to check whether given three points fall on one straight line or not */
#include<stdio.h>
int main()
{
int x1, x2, x3, y1, y2, y3 ;
printf("\nEnter the Co-ordinates of first point(x1,y1)");
scanf("%d%d",&x1, &y1);
printf("\nEnter the Co-ordinates of 2nd point(x2,y2)");
scanf("%d%d",&x2, &y2);
printf("\nEnter the Co-ordinates of 3rd point(x3,y3)");
scanf("%d%d",&x3, &y3);
if( (y2-y1)/(x2-x1)==(y3-y2)/(x3-x2) )
printf("The three points lie on straight line");
else
printf("The three points do not lie on straight line");
return 0;
}
will not run for slope = 0
ReplyDeletewhat if x2-x1=0
ReplyDeleteRuntime error for infinity slope
ReplyDelete