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

Use the boolean operator AND [&&] to include two or more conditions

  • Use the AND operator && to have the program check if both of two conditions, or all of the multiple conditions, are true. 

NOTE: In the example above,  the  if  statement  is actioned only if the Bumper Switch is pressed and 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 and Screen are both pressed.    
        if(Bumper.pressing()==true && Brain.Screen.pressing()==true){