Infolinks - Earn Easy Money

Saturday, April 4, 2015

C++ program to find that all points lies on same line or not

#include <iostream>
using namespace std ;
int main (  )
{
int x1 , y1 , x2 , y2 , x3 , y3 , s1 , s2 ;
cout <<" Enter the Value of x1 ";
cin >> x1 ;
cout <<" Enter the value of x2 ";
cin >> x2 ;
cout <<" Enter the value of x3 ";
cin >> x3 ;
cout <<" Enter the value of y1 ";
cin >> y1 ;
cout <<" Enter the value of y2 ";
cin >> y2 ;
cout <<" Enter the value of y3 ";
cin >> y3 ;
s1 = ( y2 - y1 ) + ( x2 - x1 );
s2 = ( y3 - y2 ) + ( x3 - x2 );
if( s1 == s2 )
{
cout <<" All these points falls on same line ";
}
else
{
cout <<" All these points does not falls on same line ";
}
return 0 ;
}

No comments:

Post a Comment

Must drop your comments about post.