Monday, 16 June 2014

C++ program to check whether three points lies on one straight line



Here is a C++ program to check whether three points lies on one straight line


 SOURCE CODE OUTPUT
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    int a,b,c,d,e,f;
    float g,h,i;
    cout<<"Enter x1,y1,x2,y2,x3,y3 ";
    cin>>a>>b>>c>>d>>e>>f;
    g=((d-b)/10.00)/((c-a)/10.00);
    h=((f-b)/10.00)/((e-a)/10.00);
    i=((f-d)/10.00)/((e-c)/10.00);
    if(g==h && g==i)
        cout<<"Three points are colinear";
    else
       cout<<"Three points are not colinear";
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment