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.
(Note: In a triangle, the sum of the lengths of any two sides is greater than the length of the third
side.)
#include <iostream>
using namespace std;
class triangleShape{
public:
int a,b,c;
void getLengths(){
cout<<"Enter the lenghts: ";
cin>>a>>b>>c;
}
void display(){
if(a==b||a==c||b==c){
cout<<"The triangle is isosceles";
}
else if(a==b==c){
cout<<"Triangle is equilateral ";
}
else if((a*a+b*b)==(c*c)||(a*a+c*c)==(b*b)||(c*c+b*b)==(a*a)){
cout<<"Triangle is a right angle triangle";
}
else{
cout<<"Scalene triangle";
}
}
};
int main()
{
triangleShape t;
t.getLengths();
t.display();
return 0;
}
Comments
Leave a comment