Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

The Type bool [6/9]

The result of comparison operators is a value of type bool.

* * *

The expression not(7<>7) must use parentheses because of the priority of operator not. If this expression is written witout parentheses, as not 7<>7, then it is equivalent to (not 7)<>7, which doesn't make any sense.

Normally, instead of writing not(7<>7), one would simply write a simpler but equivalent expression 7=7.

The problem arises when a programmer wants to negate the expression 7=7, so he/she writes not 7=7, which is incorrect. This expression can be correctly written as not(7=7), or simply as 7<>7.

Uncomment the erroneous line to see the error message. Then correct the error.

* * *

The inequality operator <> can be written in an altentative way as !=.

The equality operator = can be written in an altentative way as ==.

Loading...