Hi,
i am having some problems writing down the source code that can figure out all the types of triangle(isosceles,scalene,equilateral & right trianlge).
here are the things that i need to do:
- to determine if the entered sides form a valid triangle or not.
- to determine the types of triangle.
and below is my work that is only half done...
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
double a, b, c;
char sideA, sideB, sideC;
if((sideA!=sideB)&&(sideB!=sideC)&&(sideA!=sideC))
{
cout<<"\nEnter the length of "<<sideA<<":\n";
cin>>a;
cout<<"\nEnter the length of "<<sideB<<":\n";
cin>>b;
cout<<"\nEnter the length of "<<sideC<<":\n";
cin>>c;
}
if(sideA+sideB<sideC||sideB+sideC<sideA||sideA+sideC<sideB)
{
cout<<"\nIt is not a Triangle.<<\n";
}
else if (sideA==sideB&&sideB==sideC)
{
cout<<"\nIt is an equilateral triangle.\n";
}
else if (sideA==sideB||sideB==sideC||sideA==sideC)
{
cout<<"\nIt is an isoceles triangle.\n";
if (((sideA*sideA)+(sideB*sideB)==(sideC*sideC))||((sideA*sideA)+(sideC*sideC)==(sideB*sideB))||((sideB*sideB)+(sideC*sideC)==(sideA*sideA)))
{
cout<<"\nIt is a right triangle.\n";
}
else
{
cout<<"\nIt is not a right triangle.\n";
}
}
else
{
cout<<"\nIt is a scalane triangle.\n";
}
can someone pls help me out...
thx.