In C++, boolean values are used to store true or false conditions. They help programmers make decisions and control program flow.
Declaring a Boolean Variable
To define a boolean variable, use the bool keyword. A boolean can only hold two possible values: true or false.
Example
#include <iostream>
using namespace std;
int main() {
bool isMotorcycleFast = true;
bool isHelmetOptional = false;
cout << isMotorcycleFast; // Outputs 1 (true)
cout << isHelmetOptional; // Outputs 0 (false)
return 0;
}
Boolean Values in C++
trueis internally represented as1.falseis internally represented as0.
This means boolean values can also be used in logical operations and conditional statements.


