There are other possible characters after 'z'
and below 'a'
(ascii table), so it’s necessary to do both upper and lower bounds checks with &&
. If you used the ||
operator then the statement could execute if the character were any value, because ALL characters are greater than 'a'
or less than 'z'
.
solved Can I use Logical OR(||) operator instead of Logical AND(&&) operator [closed]