DevAcademia lesson/C++ Basics
Boolean Values
Topic progressTopic 35 of 109 - 32% complete
~4 min lesson13 learning blocks1 code examples1 checks/interactions
Lesson outline
Introduction to Booleans
The bool type in C++ can hold only two values: true or false.
Booleans are widely used in conditions that control program flow, such as conditional statements and loops.
Boolean Declaration
Example of declaring and printing boolean variables:
Boolean Size and Values
Important properties of the bool type in C++:
| Property | Description |
|---|---|
| Size | Implementation-defined; at least 1 byte (most platforms use 1 byte) |
| true value | Integer → bool: any non-zero becomes true. Bool → integer: true converts to 1. |
| false value | Integer → bool: 0 becomes false. Bool → integer: false converts to 0. |
| Default value | Locals with automatic storage are uninitialized (indeterminate) until assigned; static/global booleans are zero-initialized to false. |
Was this topic clear?