Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+10 votes
asked in CSC211_Winter2018 by (1 point)

3 Answers

+6 votes

No, these operators are not the same.

"!=" shows that something is not equal to another thing. For example "x != 0"
This means that the value "x" is not equal to 0.

"= false" only sets a the value of something, such as "x", to false.

x == false would compare false with the value of the boolean variable x

answered by (1 point)
+6 votes

No, they are not the same. != is checking whether two things are "not equal" to each other. You can use this on integers... e.g. (6 != 7) would evaluate to true, and (6 != 6) would evaluate to false.

x == false on the other hand, is checking whether x is specifically equal to the value false.

6 == false would evaluate to false, and true == false would evaluate to false, but false == false would evaluate to true!

answered by (3.5k points)
+3 votes

No these two are not the same thing. For example (x != 3) is saying that the condition is true when it does not equal that specific value. Saying (x==false) means that no matter what x is, it is false, which is a boolean value.

answered by (1 point)
...