C++ Boolean Data Types

Boolean Types

A boolean data type is declared with the bool keyword and can only take the values true or false. When the value is returned, true = 1 and false = 0.


#include <iostream>
using namespace std;

int main() {
  bool isCodingFun = true;
  bool isFishTasty = false;
  cout << isCodingFun << "\n";
  cout << isFishTasty;
  return 0;



Boolean values are mostly used for conditional testing, which you will learn more about in a later chapter.

Leave a Reply

Your email address will not be published.