0

Hey guys, here's the question I'm asked.

**a.***Define an enumeration type, triangleType, that has the values scalene, isosceles, euilateral, and noTriangle.*

**b.***Write a function, triangleShape, that takes as parameters three numbers, each of which represents the length of a side of the triangle. The function should return the shape of the triangle.*

**c.***Write a program that prompts the user to input the length of the sides of a triangle and outputs the shape of the triangle.*

Here is my code:

```
#include <iostream>
using namespace std ;
enum triangleType { scalene , isosceles , equilateral , noTriangle } ;
triangleType triang ( double , double , double ) ;
int main()
{
double a ;
double b ;
double c ;
int shape ;
cout << "Side 'a' length: " << flush ;
cin >> a ;
cout << "Side 'b' length: " << flush ;
cin >> b ;
cout << "Side 'c' length: " << flush ;
cin >> c ;
shape = triang ( a , b , c ) ;
switch (shape)
{
case 0:
cout << "Triangle Shape: Scalene" << endl ;
break ;
case 1:
cout << "Triangle Shape: Isosceles" << endl ;
break ;
case 2:
cout << "Triangle Shape: Equilateral" << endl ;
break ;
case 3:
cout << "Triangle Shape: -- No Shape --" << endl ;
break ;
}
return 0 ;
}
triangleType triang ( double a , double b , double c )
{
triangleType shape ;
if ( ( a > (b + c) ) || ( b > (a + c) ) || ( c > (a + b) ) )
shape = noTriangle ;
else if ( ( a == b ) && ( a == c ) && ( b == c ) )
shape = equilateral ;
else if ( a != b && a != c && b != c )
shape = scalene ;
else
shape = isosceles ;
return shape ;
}
```

It works, I just want to know if I'm answering the question correctly?

*Edited 3 Years Ago by mike_2000_17*: Fixed formatting