samedi 3 décembre 2016

Checking to See which of the three conditions in the If Statement was True in Else If, if one was not?

Assumptions: 1 of 3 of the conditions will be 0.

If I have an if statement defined as follows:

   if ((condition1 == 0) || condition2 == 0) || condition3 == 0)) {
     do something 
   }

and 3 following else if statements:

else if (condition1 != 0) {
  do something
  print which of condition 2 or 3 was 0
}

else if (condition2 != 0) {
  do something
  print which of condition 1 or 3 was 0
}

else if (condition3 != 0) {
  do something
  print which of condition 1 or 2 was 0
}

I was thinking perhaps putting nested if statements in the first if statement to see which of the three was 0.

Aucun commentaire:

Enregistrer un commentaire