Solution:
Next to each valid expression you will find the value the expression evaluates to. Below that you will see a series of expressions that expose the order in which these operators are evaluated. For each invalid expression you will see a brief explanation of the error.
However, on CodeWarrior 11 this is not an error and the
expression evaluates as follows.
(ch != '03') || (ch == 'A')
(1) || (ch == 'A')
(1) || (0)
1
More accurately, the second subexpression in the expression is never evaluated since the first subexpression is True and the expression ``short circuits'' to True.
Note that the string class assumes a lexicographic ordering or alphabetical ordering on strings.
The above expression produces an error on CodeWarrior 11 because the string being used does not contain functions that overload the operators < and >. This is unfortunate and is not true of most other implementations of the string class including Astrachan's string class.
Note that 'T' comes before 't' in the ASCII table and hence the subexpression ("Turing" > "turning") is False. Because of short-circuited evaluation, the expression evaluates to False as soon as the first subexpression evaluates to False. Hence, the second subexpression is not evaluated. If it were evaluated, it would cause a division by 0 error.
The above expression produces also an error on CodeWarrior 11 because of the same reason that Expression 6 does.
Note that log10() is a function defined in the math.h header file. Also note that length() is a member function of the string class that returns the length of the string object it is applied to.
Note the use of short-circuited evaluation here.
"Turing3" comes before "Turing?" because '3' comes before '?' in the ASCII table.
The above expression produces also an error on CodeWarrior 11 because of the same reason that Expressions 6 and 7 do.