Rather use the switch - statement for this purpose:
Instead of:
if ($i == 0) {
print "i equals 0";
}
if ($i == 1) {
print "i equals 1";
}
if ($i == 2) {
print "i equals 2";
}
try using
switch ($i) {
case 0:
print "i equals 0";
break;
case 1:
print "i equals 1";
break;
case 2:
print "i equals 2";
break;
}
or i.e
switch ($i) {
case 0:
case 1:
case 2:
print "i is less than 3 but not negative";
break;
case 3:
print "i is 3";
}
or
A special case is the default case. This case matches anything that wasn't matched by the other cases. For example:
switch ($i) {
case 0:
print "i equals 0";
break;
case 1:
print "i equals 1";
break;
case 2:
print "i equals 2";
break;
default:
print "i is not equal to 0, 1 or 2";
}
Returning to your specific question:
Both if-clauses contain a 'true' statement
--A-clause---------------------------
if (a==1 or a==3)
print (" a=1 ,could also be 3");
--B-clause----------------------------
elseif (a==2 or a == 3)
print("a=2 , could also be 3");
Input->2
A-clause = FALSE
B-clause = TRUE, a is 2 or 3 !
Input->3
A-clause = TRUE, a is 1 or 3
B-clause = TRUE, a is 2 or 3
because:
when using 'or', only one of the compared
has to be true in order fpr the if clause
to become true
cu
e-wizard