Tuesday, 31 July 2018

Co-ordinate Geometry

===========================================================================
                                CODING



#include<iostream.h>
#include<conio.h>
#include<math.h>

void main()
{
clrscr();
float a1,a2,b1,b2,c1,c2,s1,s2,s3,H1,H2,H3,Ar;
cout<<"Want to Find type of Triangle:- \n\n¯Enter the  co-ordinates of point A:- \n    Enter x co-ordinate: ";
cin>>a1;
cout<<"\n    Enter y co-ordinate: ";
cin>>a2;
cout<<"\n\n¯Enter the  co-ordinates of point B:- \n    Enter x co-ordinate: ";
cin>>b1;
cout<<"\n    Enter y co-ordinate: ";
cin>>b2;
cout<<"\n\n¯Enter the  co-ordinates of point C:- \n    Enter x co-ordinate: ";
cin>>c1;
cout<<"\n    Enter y co-ordinate: ";
cin>>c2;
Ar=0.5*(a1*(b2-c2)+b1*(c2-a2)+c1*(a2-b2));
s1=sqrt(pow(b1-a1,2)+pow(b2-a2,2));
s2=sqrt(pow(c1-b1,2)+pow(c2-b2,2));
s3=sqrt(pow(c1-a1,2)+pow(c2-a2,2));
H3=sqrt(pow(s1,2)+pow(s2,2));
H1=sqrt(pow(s2,2)+pow(s3,2));
H2=sqrt(pow(s1,2)+pow(s3,2));
if(Ar==0)
{
cout<<"\nThe points do not form a Triangle but are colliner points as area="<<fabs(Ar);}
else
{
if(s1==s2 && s2==s3)
{
cout<<"\nThe points form a eq. Triangle with area="<<fabs(Ar)<<" And sides="<<s1<<", "<<s2<<", "<<s3;}
else if((s1==s2 && s2!=s3) || (s1!=s2 && s2==s3) || (s1==s3 && s2!=s3))
{
cout<<"\nThe points form a isoceles Triangle with area="<<fabs(Ar)<<" And sides="<<s1<<", "<<s2<<", "<<s3;}
else if(s3==H3)
{
cout<<"\nThe points form a Right angle Triangle with area="<<fabs(Ar)<<" And hypotenuse="<<s3<<" And sides="<<s1<<", "<<s2<<", "<<s3;}
else if(s2==H2)
{
cout<<"\nThe points form a Right angle Triangle with area="<<fabs(Ar)<<" And hypotenuse="<<s2<<" And sides="<<s1<<", "<<s2<<", "<<s3;}
else if(s1==H1)
{
cout<<"\nThe points form a Right angle Triangle with area="<<fabs(Ar)<<" And hypotenuse="<<s1<<" And sides="<<s1<<", "<<s2<<", "<<s3;}
else if(s3==H3 && s1==s2)
{
cout<<"\nThe points form a Right angle isoceles Triangle with area="<<fabs(Ar)<<" And hypotenuse="<<s3<<" And sides="<<s1<<", "<<s2<<", "<<s3;}
else if(s2==H2 && s1==s3)
{
cout<<"\nThe points form a Right angle isoceles Triangle with area="<<fabs(Ar)<<" And hypotenuse="<<s2<<" And sides="<<s1<<", "<<s2<<", "<<s3;}
else if(s1==H1 && s2==s3)
{
cout<<"\nThe points form a Right angle isoceles Triangle with area="<<fabs(Ar)<<" And hypotenuse="<<s1<<" And sides="<<s1<<", "<<s2<<", "<<s3;}
else
{
cout<<"\nThe Triangle is a scalene triangle with area="<<fabs(Ar)<<" And sides="<<s1<<", "<<s2<<", "<<s3;}
}
getch();
}



===========================================================================


                                OUTPUT



No comments:

Post a Comment