Write a pseudocode to get the sides of a triangle from a user and check whether the triangle is an isosceles, equilateral or scalene. Output an appropriate message stating the type of triangle based on the measurements given.
#include <iostream>
using namespace std;
int main()
{
double a, b, c;
cout << "Enter a: ";
cin >> a;
cout << "Enter b: ";
cin >> b;
cout << "Enter c: ";
cin >> c;
if (a <= 0 || b <= 0 || c <= 0)
{
cout << "Triangle does not exist!" << endl;
system("pause");
return 0;
}
if (a + b <= c || a + c <= b || b + c <= a)
{
cout << "Triangle does not exist!" << endl;
system("pause");
return 0;
}
if (a == b && a == c)
{
cout << "Triangle is equilateral!" << endl;
system("pause");
return 0;
}
if (a == b || b == c || c == a)
{
cout << "Triangle is isosceles!" << endl;
system("pause");
return 0;
}
cout << "Triangle is scalene!" << endl;
system("pause");
return 0;
}
Comments
Leave a comment