Given three points (x1, y1), (x2, y2) and (x3, y3), write a program to check if all the three points fall on one straight line.
void main()
{
float x1,x2,x3,y1,y2,y3;
printf("\nEnter the three coordinates (x1,y1),(x2,y2),(x3,y3)");
scanf("%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3);
if ((y2-y1)/(x2-x1)==(y3-y2)/(x3-x2))
printf("\nThe three points fall on the same line");
else
printf("\nThe three points are not collinear");
}
Subscribe to:
Post Comments (Atom)
1 1 1 2 1 3
ReplyDeletefor this input runtime error is displaying
This comment has been removed by the author.
ReplyDeletevoid main()
ReplyDelete{
float x1,x2,x3,y1,y2,y3,temp;
printf("\nEnter the three coordinates (x1,y1),(x2,y2),(x3,y3)");
scanf("%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3);
if(x1==x3)
{
temp=x1;
x1=y1;
y1=temp;
temp=x2;
x2=y2;
y2=temp;
temp=x3;
x3=y3;
y3=temp;
}
if ((y2-y1)/(x2-x1)==(y3-y2)/(x3-x2))
printf("\nThe three points fall on the same line");
else
printf("\nThe three points are not collinear");
}
This comment has been removed by the author.
ReplyDeletewhy u swap when x1 and x3 are equal?
ReplyDeleteelse it will show exception error divide by zero, which is runtime error
ReplyDeleteSlots Casinos Near DC, Philadelphia, MD - Mapyro
ReplyDeleteFind and compare slot machines, video poker, and 양주 출장마사지 blackjack at 영주 출장안마 nearly 속초 출장안마 30000 Casino Wyandotte casinos in 군산 출장마사지 Maryland Heights, 부산광역 출장마사지 MD.