---
title: 1.16 Boolean Data Type
description: "The `bool` data type represents logical values. It can store only one of two possible values: `true` or `false`. Boolean values are commonly used to represent the result of comparisons and control program flow. This example demonstrates how to declare…"
url: "https://edcret.in/docs/cpp-programming/basic-refreshers-cplusplus/1-16-boolean-data-type/"
updated: "2026-07-28"
category: C++ Programming / Basic Refreshers
---

# 1.16 Boolean Data Type

The `bool` data type represents logical values. It can store only one of two possible values: `true` or `false`. Boolean values are commonly used to represent the result of comparisons and control program flow.

This example demonstrates how to declare and display a Boolean variable.

## Source Code

```
#include <iostream>

int main()
{
    bool is_logged_in = true;

    std::cout << "User Logged In: " << is_logged_in << '\n';

    return 0;
}
```

## Output

```
User Logged In: 1
```

## Explanation

- `bool is_logged_in = true;` declares a Boolean variable and initializes it with the value `true`.
- A `bool` object can store only `true` or `false`.
- By default, `std::cout` prints Boolean values as integers, where `true` is displayed as `1` and `false` as `0`.
- The manipulators `std::boolalpha` and `std::noboolalpha` can be used to display Boolean values as the words `true` and `false` instead of `1` and `0`.
- `std::cout << "User Logged In: " << is_logged_in << '\n';` prints the value stored in the Boolean variable.
- `return 0;` terminates the program successfully.
