Code:
#include <iostream>
using namespace std;
//Function Prototypes.
bool isTriangle(float x, float y, float z);
bool isIsoceles(float x, float y, float z);
bool isEquilateral(float x, float y, float z);
bool isScalene(float x, float y, float z);
bool isAcute(float x, float y, float z);
bool isRight(float x, float y, float z);
bool isObtuse(float x, float y, float z);
//Main Function
int main ()
{
//Declare variables.
float A;
float B;
float C;
//Get lengths of triangle.
cout << "Please enter the triangle lengths:" << endl;
cout << "length 1: ";
cin >> A;
cout << "length 2: ";
cin >> B;
cout << "length 3: ";
cin >> C;
//Order the lengths.
if (A>B)
{
float temp;
temp = A;
A = B;
B = temp;
}
if (A>C)
{
float temp;
temp = A;
A = C;
C = temp;
}
if (B>C)
{
float temp;
temp = B;
B = C;
C = temp;
}
//Display order.
cout << "Lengths in nondecreasing order: "<< A << "," << B << ","
<< C <<endl;
//Function calls and final output.
cout<<"The triangle is: ";
if(isTriangle(A,B,C))
{
if(isIsoceles(A,B,C))
cout<<"Isoceles"<<endl;
}
else if(isEquilateral(A,B,C))
{
cout<<"Equilateral"<<endl;
}
else if(isScalene(A,B,C))
{
cout<<"Scalene"<<endl;
}
else if(isAcute(A,B,C))
{
cout<<"Acute"<<endl;
}
else if(isRight(A,B,C))
{
cout<<"Right"<<endl;
}
else if(isObtuse(A,B,C))
{
cout<<"Obtuse"<<endl;
}
else
{
cout<<"Illegal"<<endl;
return 0;
}}
//Function Definitions.
bool isTriangle(float x, float y, float z)
{
if (x>0 && (x + y >z))
{
return true;
}
else
{
return false;
}}
bool isIsoceles(float x, float y, float z)
{
if ((x=y) || (y=z))
{
return true;
}
else
{
return false;
}}
bool isEquilateral(float x, float y, float z)
{
if ((x=y) && (y=z))
{
return true;
}
else
{
return false;
}}
bool isScalene(float x, float y, float z)
{
if (x<y && (y<z))
{
return true;
}
else
{
return false;
}}
bool isObtuse(float x, float y, float z)
{
if (((x*x)+(y*y))<(z*z))
{
return true;
}
else
{
return false;
}}
bool isRight(float x, float y, float z)
{
if (((x*x)+(y*y))==(z*z))
{
return true;
}
else
{
return false;
}}
bool isAcute(float x, float y, float z)
{
if (((x*x)+(y*y))>(z*z))
{
return true;
}
else
{
return false;
}}