Hey guys/gals, I could use some help in finishing my code I need to be able to input whatever numbers to get a right triangle and also numbers that will show it is not a right triangle but I am stuck on what to do next. any help is appreciated.
here is what I have so far:
cout<<"Enter side a: " <<endl;
cin>>a;
cout<<endl;
cout<<"Enter side b: " <<endl;
cin>>b;
cout<<endl;
cout<<"Enter side c: "<<endl;
cin>>c;
cout<<endl;
if (cin.fail()==true)
{
cout<<"Error, this is not a numericle value."<<endl;
cin.clear();
cin.ignore(50, '\n');
}
else if (a,b,c <=0)
{
cout<<"Has to be a positive number."<<endl;
}
else
{
a^2 == b^2 + c^2;
b^2 == a^2 + c^2;
c^2 == a^2 + b^2;
These bits are meaningless in the context in which you used them. The equality operator will evaluate to true if it is a right triangle (in at least one of those scenarios), but you do nothing with it.
Also, is there a reason you declare a, b, and c as short? Wouldn't it better be suited as unsigned int? (Unless you want a length cap of 32767)
Hi rusty4118, I need to clarify something. The aim of this program is to check if the user's lengths input is a right-angle triangle? Because not all inputs can be a right-angle triangle. It must satisfy this condition: a^2 + b^2 = c^2 (where c is the longest length).
Like what Thumper has mention, you need not check all: