A good answer might be:
(It would probably be better in this simple case
to reverse the bodies of
the true-branch and the false-branch.
But say that there were other considerations that made this
undesirable.)
|
Precidence of NOTIt is important to put parentheses around the entire expression who's true/false value you wish to reverse. Evaluation of the example proceeds like this:
The NOT operator has high precidence, so it will be done first (before arithmetic and relational operators) unless you use parentheses. For example, without the parentheses in the above expression, this would happen: Since ! has high precidence, the compiler will try to apply it to speed, which won't work.!speed > 400 && memory > 32 --+--- illegal: can't use ! on an arithmetic variable Sometimes using NOT can lead to confusing program errors. It is usually best to say directly what you mean and arrange the program logic so that this works. |
QUESTION 22:What is the true/false value of the following: Click Here after you have answered the question!( true || false ) |