Types of Triangles Based on Angles
On the basis of angles, triangles are classified into the following types:
- Acute Triangle: When all the angles of a triangle are acute, that is, they measure less than 90°, it is called an acute triangle.
- Right Triangle: When one of the angles of a triangle is 90°, it is called a right triangle.
- Obtuse Triangle: When one of the angles of a triangle is an obtuse angle, that is, it measures greater than 90°, it is called an obtuse triangle.
my code:
#include<iostream>
using namespace std;
int Triangle(int ang1, int ang2, int ang3);
int main()
{
int ang1, ang2, ang3;
cout << "Enter Angle 1: ";
cin >> ang1;
cout << "Enter Angle 2: ";
cin >> ang2;
cout << "Enter Angle 3: ";
cin >> ang3;
int sum = Triangle(ang1, ang2, ang3);
//check
if ((ang1 < 90 && ang2 < 90 && ang3 < 90) && (sum = 180))
cout << "Acute Triangle." << endl;
else if ((ang1 == 90 || ang2 == 90 || ang3 == 90) && (sum = 180))
cout << "Right Triangle." << endl;
else
cout << "Obtuse Triangle." << endl;
return 0;
}
//
int Triangle(int ang1, int ang2, int ang3)
{
return (ang1 + ang2 + ang3);
}
No comments:
Post a Comment