Monday, December 10, 2012

Checking for Collinear coordinate points in C language

#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int x1,x2,x3,y1,y2,y3;
float s1,s2,s3;
printf("\n Enter the first point coordinates");
scanf("%d%d",&x1,&y1);
printf("\n Enter the second point coordinates");
scanf("%d%d",&x2,&y2);
printf("\n Enter the third point coordinates");
scanf("%d%d",&x3,&y3);
/* calculating slope between the points*/
s1=abs(x2-x1)/abs(y2-y1);
s1=abs(x3-x1)/abs(y3-y1);
s3=abs(x3-x2)/abs(y3-y2);
if((s1==s2)&&(s1==s3))
printf("\n Points entered are collinear");
else
printf("\n Points entered are not collinear");
printf("\n Press any key to exit");
getch();
}

No comments:

Post a Comment

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...