Answer to Question #200989 in C++ for Master j

Question #200989

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.


1
Expert's answer
2021-05-31T05:39:39-0400
#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;
}

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