Please help, I am writing a program to take in 3 values and return the shape of a triangle. The program runs, but not quite right. Instead of returning the shape of a triangle, it returns a smiley face....which really surprised me. Can anybody help? The code I have is:
#include <iostream>
using namespace std;
enum triangleType {scalene, isosceles, equilateral, noTriangle};
char triangleShape (int&, int&, int&);
int main()
{
int side1, side2, side3;
char shape;
cout<<"Please enter the desired length of the sides of the triangle."<<endl;
cin>> side1>>side2>>side3;
shape = triangleShape (side1, side2, side3);
cout<<"The shape of the triangle is: "<<shape<<endl;
return 0;
}
char triangleShape (int& side1, int& side2, int& side3)
{
char shape;
if (side1==side2 && side2==side3)
shape = equilateral;
else if (side1==side2 || side1==side3 || side2==side3)
shape = isosceles;
else if (side1!=side2 && side1!=side3)
shape = scalene;
else if (side1+side2<side3 || side1+side3<side2 || side2+side3<side2)
shape = noTriangle;
return shape;
}