Answer to Question #265314 in C++ for Usama

Question #265314

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.)


1
Expert's answer
2021-11-14T09:21:59-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS