+ 1

Need a clear idea about Boolean. What is it? Why? and how it is used?

Boolean

11th Feb 2019, 4:47 AM
Niaz Makhdum
Niaz Makhdum - avatar
6 Answers
+ 9
Boolean refers to the value of 1/0 or True/False. This data type is used for simple flags that track true/false conditions.
11th Feb 2019, 4:58 AM
Arushi Singhania
Arushi Singhania - avatar
+ 5
It is declaring a boolean variable online with value true. Online can only be true or false. Hence, boolean variable is used.
11th Feb 2019, 5:05 AM
Arushi Singhania
Arushi Singhania - avatar
+ 2
Booleans are usually used with if/else statements to evaluate if a certain state is true or not: if(online == true) { puts("You're online"); } else { puts("You're offline"); }
11th Feb 2019, 7:56 AM
Anna
Anna - avatar
+ 1
Arushi Singhania can you please elaborate the following code? "boolean online = true" Please elaborate a little more.
11th Feb 2019, 5:03 AM
Niaz Makhdum
Niaz Makhdum - avatar
0
think of it outside the coding it shall become clear. a two state condition. the light switch is on of off, the shoelace tied or untied? the coffee use milk or black without, sweet with sugar or none. left or right up or down. matter or anti matter. George Boole who these things are named after gave us Boolean Algebra and was largely self taught. do a bit of research into him his work it all becomes clearer
11th Feb 2019, 11:50 AM
peter
peter - avatar
- 1
no
11th Feb 2019, 11:38 AM
Kwonk
Kwonk - avatar