+ 1

When do we use bool variable ?

19th Sep 2017, 8:50 PM
Ahmad Alzohaile
Ahmad Alzohaile - avatar
7 odpowiedzi
+ 8
When a true/false value is required to be stored/tracked http://www.learncpp.com/cpp-tutorial/26-boolean-values/
19th Sep 2017, 9:07 PM
jay
jay - avatar
+ 5
Any time you have a yes or no question/answer.
20th Sep 2017, 2:26 AM
John Wells
John Wells - avatar
+ 5
I used one here to verify my number. https://code.sololearn.com/cF7iOkU73BYy/?ref=app
21st Sep 2017, 4:10 PM
John Wells
John Wells - avatar
+ 2
Think of it as a fork in the road of your code. If true, do one thing, if false do something else. Boolean variables should be named appropriately too - by convention you should prefix your variable names with "Is". For example, if determining that the side of a coin is heads I might create the variable name "IsHeads" .
20th Sep 2017, 1:39 PM
Mike
Mike - avatar
+ 1
In any flow control statements (if/else, switch, loops...)
19th Sep 2017, 9:09 PM
Dmitry Semigradsky
Dmitry Semigradsky - avatar
+ 1
yes
8th Oct 2017, 2:43 PM
Stas Holovachuk
Stas Holovachuk - avatar
0
for true or false
21st Sep 2017, 1:12 PM
Sunil Sortur
Sunil Sortur - avatar