-
Quote:
Originally posted by Sang-drax
You know,
Code:
if (((letter >= 'A') && (letter <= 'Z')) ||
((letter >= 'a') && (letter <= 'z')))
can be written as
Code:
if (letter >= 'A' && letter <= 'Z' ||
letter >= 'a' && letter <= 'z')
IMO, the second way looks better.
Oh thank you so much. It is allot easier to do that than the other way for sure. One question. Why does the other one have so many of those when the second one works fine with only 2?
-
Either the author of the book is trying to show the seperate comparisons or it is a badly written book.
-
Probably to make it clear which expressions are to be evaluated first. If you don't want to take the time to see which expressions are evaluated first you can simply put in parentheses. In this case it works without them because inequeality relational (<=, <...) have precedence, followed by logical AND and finally logical OR
-
>>It is allot easier to do that than the other way for sure.
But it still doesn't guarantee what's been entered is a letter (see my previous post).