So, I'm running some code and I got it to work, but I have two if else statements.
Let's say
if( a == 'b'||'c') && (d!=0)
{
do operation1;
}
else if( a == 'e'||'f') && (d!=0)
{
do operation2;
}
operation 1 runs by default when my code was structured that way. What do I mean by default? If I tried typing the input 'e' or 'f' it would do operation 1 as if I had typed in 'b' or 'c' But then I tried something different.
if(a == 'b') || (a == 'c') && (b != 0) { do operation 1;}
else if (a == 'e') || (a == 'f') && (b!= 0){do operation 2;}
See NOW operation 1 and 2 are working as intended.
Why does this happen?
Aucun commentaire:
Enregistrer un commentaire