hi all of u,,can understand how to get his equation is done

Write your question here.
Write a program to prompt user to enter 3 sides of a triangle. The program then determines whether the dimensions could form a valid triangle. If it is, the program needs to determine the type of triangle and all its three internal angles: alpha, beta and theta, where alpha is the biggest angle, beta is the second and theta is the smallest. Inform the user when the 3 sides cannot form a triangle.
#include <iostream.h>

main()
{
//variables
float aside, bside, cside;
//enter side a
cout<<"enter the length of side a "<<endl;
cin>>aside;
//enter side b
cout<<"enter the length of side b "<<endl;
cin>>bside;
//enter side c
cout<<"enter the length of side c "<<endl;
cin>>cside;

// all sides equal
if(aside==bside && bside==cside)
cout << "Equilateral triangle\n";

// at least 2 sides equal
else if(aside==bside || aside==cside || bside==cside)

cout << "Isosceles triangle\n";
// no sides equal
else
cout << "Scalene triangle\n";
}
First thing to do is sort your sides. Make a the smallest, b the middle, and c the largest. That will help you keep things straight later.

Next, if any side is negative, it is not a triangle.
If any side is zero, it is not a triangle.
Finally, if the sum of the two smaller sides is less than the largest side, then it is not a triangle.

Otherwise, you've got yourself a triangle. To find the interior angles, use the Law of Cosines.
http://en.wikipedia.org/wiki/Law_of_cosines

You'll need to #include <cmath> and use the acos() function to get the arccosine function (aka inverse cosine). If you're lost on the algebra, look down at the "Applications" section where it says "γ = arccos (...)".

Hope this helps.
Topic archived. No new replies allowed.