+ 5

These are useful when you need a data type that can only have one of two values, such as Yes/No, On/Off, True/False.

I can't understand this lines​ described above ??? please explain it and like it!!!!!!

22nd Apr 2017, 9:25 AM
🎆Sourav Subhakant Dash🔥🔥
🎆Sourav Subhakant Dash🔥🔥 - avatar
2 Antworten
+ 15
So this is about boolean values which are true and false. I am going to give you an example: You have a TV. We have a variable called TVTurnedOn... Which is false. If we turn on the tv with the remote TVTurnedOn will be true and the TV will work. if TVTurnedOn is true then show images and sound else then do not show images and sound.. Is this clear enough?
22nd Apr 2017, 9:45 AM
Gami
Gami - avatar
+ 2
Has the game started? the answer is yes/no, so you can store that value in a boolean variable, like so bool game_started = true Is this condition true or false? The only two valid answers are true or false, so you could do bool condition = false Whenever a valid value can only be one of two values, a boolean variable is used, which only can store true or false. another ex: is the light on or off? it can only be on or off, with no values inbetween, so you can use a boolean.
22nd Apr 2017, 9:48 AM
Bebida Roja
Bebida Roja - avatar