printf("The Angle A Is: %f", (acos((b*b + c*c - a*a)/2*b*c)*180/3.14159265359));
This is a simple program which returns the angle A if the sides a, b, c are entered.
I have checked whether the triangle is possible or not.
if((a+b) <= c || (b+c) <= a || (c+a) <= b)
return 0;
I am getting correct output for some inputs. For 1 1 1
I get 60
.
But for the input 7 7 7
I am getting -1.#IND00
instead of the 60
I should be getting.
Now I came to know by reading another answer that it stands for indeterminate values (specifically a non-zero number divided by zero) but here that is not the case.
So why am I getting this error?
Here is the full program:
int main()
{
float a, b, c;
printf("Enter The Sides of The Triangle(a, b, c): ");
scanf("%f %f %f", &a, &b, &c);
if((a+b) <= c || (b+c) <= a || (c+a) <= b)
{
printf("Triangle Not Possible.");
return 0;
}
printf("The Angle A Is: %f", (acos((b*b + c*c - a*a)/2*b*c)*180/3.14159265359));
}