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;
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.
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 (...)".