You're given the length of three sides a, b, and c respectively. Now If these three sides can form an Equilateral Triangle then print 1, if these three sides can form an Isosceles Triangle then print 2, if these three sides can form a Scalene Triangle then print 3, otherwise print −1.

You're given the length of three sides a, b, and c respectively. Now If these three sides can form an Equilateral Triangle then print 1, if these three sides can form an Isosceles Triangle then print 2, if these three sides can form a Scalene Triangle then print 3, otherwise print −1.







OURSHOPKEEPER







#include <iostream>
using namespace std;
int main()
{
    int abc;
    cin >> a >> b >> c;
    if ((a == b && b == c) && ((a + b > c) && (b + c > a) && (c + a > b)))
    {
        cout << "1" << endl;
    }
    else if (((a == b && b != c) || (a != b && b == c) || (a == c && c != b)) && ((a + b > c) && (b + c > a) && (c + a > b)))
    {
        cout << "2";
    }
    else if ((a != b && b != c) && ((a + b > c) && (b + c > a) && (c + a > b)))
    {
        cout << "3" << endl;
    }
    else
        cout << "-1" << endl;
}





    


Click on the above button to download the code.



Post a Comment

If you have furthur QUERIES please let us know

Previous Post Next Post