How to use bool and for what it's uses is? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to use bool and for what it's uses is?

5th Sep 2016, 3:30 PM
Kaung Myat Thu
Kaung Myat Thu - avatar
2 Answers
+ 2
A bool (boolean) can take two different values, true or false. (The way it is defines in c++, false is 0 and true is any non-zero value.) You can use a bool to represent anything that can only have two different values. For example, the presence or absence of a property. A few logical operators: not (!): !a is true if a is false and (&&): (a && b) is true if both a and b are true or (||): (a || b) is true if either a or b is true xor (^): (a ^ b) is true if either a or b is true but not both Note that comparison operators (like >= or !=) return a bool, and that the condition of if, while, etc. is a bool.
5th Sep 2016, 4:54 PM
Zen
Zen - avatar
0
thanks a lot
5th Sep 2016, 4:56 PM
Kaung Myat Thu
Kaung Myat Thu - avatar