How to Use a Boolean OR Operator in VEX C++

Use the boolean operator OR to include at least one of the possible conditions

  • Use the OR operator || to have the program check if either of two conditions, or any of multiple conditions, is true. 

NOTE: In the example above, the if statement is actioned if the Bumper Switch is pressed or the V5 Robot Brain's screen is pressed.

NOTE: It is easier to use boolean operators if the outcomes of conditions are considered. Logical truth tables like those below are used to track input conditions and output behaviors.

Code that can be copied and pasted:

#include "robot-config.h"   

int main() {          
    //The robot moves forward unless the Bumper Switch or the Screen is pressed.         
        if(Bumper.pressing()==true || Brain.Screen.pressing()==true){