Is it legit to use brackets within an if-statement?


will if-statement want do?
code: [select]
if(pieceistaken == true && ( z!= 0 && z != 7 && z != 31 && z != 24)){



for if statement true:

  • pieceistaken must true
  • and z must not equal 0, 7, 31, or 24


i suppose without brackets, want know if works in principle. in maths (5+1)*(4+2)=6*6=36, stuff within brackets solved first.

thanks :)

in time took post question, have tested it....

edit... seems work expect code:

code: [select]
// set following variables test cases , re-upload
bool pieceistaken= true;
byte z= 31;


void setup()
{
  serial.begin(9600);
  if(pieceistaken == true && ( z!= 0 && z != 7 && z != 31 && z != 24))
  {
    serial.print("good");
  }
  else
  {
    serial.print("not good");
  }
}

void loop(){
}


Arduino Forum > Using Arduino > Programming Questions > Is it legit to use brackets within an if-statement?


arduino

Comments