C++: What is Boolean Data Type & What Does it Do?

  • Context: C/C++ 
  • Thread starter Thread starter ineedhelpnow
  • Start date Start date
  • Tags Tags
    C++ Data
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
ineedhelpnow
Messages
649
Reaction score
0
Boolean refers to a quantity that has only two possible values, true or false.

The language has the built-in data type bool for representing Boolean quantities.

thats what my book says. i don't really understand the purpose. here's a passage from my book:
Code:
int main() {
   bool isLarge = false;
   bool isNeg   = false;
   int  userNum = 0;

what is bool for? what does it do?
 
Last edited:
Physics news on Phys.org
One example would be as use for a flag that indicates when a looping construct should quit. Really though, any condition in your program that will only be either true or false is a good candidate for this data type.