The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details. |
Home Fruitful functions Boolean Values | ||
See also: Boolean Variables, Bool Functions | ||
Boolean Values
The types we have seen so far are pretty big. There are a lot of integers in the world, and even more floating-point numbers. By comparison, the set of characters is pretty small. Well, there is another type in C++ that is even smaller. It is called boolean, and the only values in it are true and false.
// do something } The operator == compares two integers and produces a boolean value. The values true and false are keywords in C++, and can be used anywhere a boolean expression is called for. For example, while (true) {// loop forever } is a standard idiom for a loop that should run forever (or until it reaches a return or break statement).
|
||
Home Fruitful functions Boolean Values |