0
The L variables would be sides of a triangle, I put them as int and I’m trying to convert to bool, I saw some people saying that this is not possible, so what kind of variable will I use and what will I do now? (I only put a piece of code due to the limitations of the question)
EQ = (L1 = L2) & (L2 = L3);
ES = (L1 != L3); (L2 != L3) & (L3 != L1);
TRI = (L1 < L2 + L3); (L2 < L1 + L3) & (L3 < L1 + L2);
Console.WriteLine("Pode se formar um triângulo?, " + TRI);
Console.WriteLine("O triângulo é EQUILÁTERO?, " + EQ);
Console.WriteLine("O triângulo é ESCALENO?, " + ES);
Console.Read();
I understood, so what can I do to be able to compare these variables and return a bool value?
– bearer seek seek lest
Just read the answer above.
– anonimo
Good, that was a better answer than I was thinking
– Glaydson Rodrigues
All right, but what will I do with the signs != e <, since it says that only expressions of assignment, call, increment, decrease and new object can be used as an instruction? If anyone can help thanks, but at least one part of the code is already solved(L1==L2) stopped giving int error relative to bool.
– bearer seek seek lest
There is already another problem and therefore another question must be asked, this one is solved and you can accept the answer if you want. Here we try to answer questions in a way useful to everyone, not to meet specific problems. In your case as a general tip you can stop using the
;
in the middle of the line because it’s breaking the statement in two, which are being evaluated separately. If you want to combine comparisons can do for exampleMinhaVariavelBool = (L1 < L2 + L3) & (outra coisa) & (outra coisa);
among other combinations. It is also possible to include the operator|
or||
.– Piovezan
Note also that it is more interesting to use
&&
that&
in your case. Between two bools it makes no difference but there is a subtle difference between the two and using wrong hides the intent of your code (ie what your code really wants to do).– Piovezan