I was searching on google and i couldnt find anywhere the "or" syntax.
i need it for example like this.
if ( ) or ( ) {
}
i know i can check it 2 times but i want the correct syntax
I was searching on google and i couldnt find anywhere the "or" syntax.
i need it for example like this.
if ( ) or ( ) {
}
i know i can check it 2 times but i want the correct syntax
acmiilangr,
I think you want the logical OR operator. The operator is: ||
Similarly, the logical AND operator is: &&
The logical NOT operator is: !
Do not get these mixed up with the bit operators: | & ^
if ((volume > MAX_VOL) || (time > MAX_TIME))``if ((value > 10) && (value < 100)) // value is 11 - 99
Regards,
-Mike
Read all about it:
thanks!!!
if ( x > y || x > z) { var++; }
I don't think you need that extra "( )", as mentioned earlier, but it is a good habit and makes the code cleaner.
if ( x > y || x > z) { var++; }
I don't think you need that extra "( )", as mentioned earlier, but it is a good habit and makes the code cleaner.
Absolutely right. Just as you don't need the '{' and '}' in the example you gave.
Regards,
-Mike