Home   |   About   |   Terms   |   Contact    
Read & Learn
 

What is bool Type in C++?

C++

☯ All C++ Articles     ☯ All Articles


A new product.




Popular Google Pages:



◕ This article is regarding What is bool Type in C++?
Last updated on: .



◕ What is bool Type in C++?

In C++, a Boolean variable is one whose value is either true or false.
The name bool came after the name of the great English mathematician George Boole.
Normally nonzero values as true and zero values as false.
This type are greatly used in the if statements.



◕ Example statements of bool type are as follows:

▨ We can use the bool type to represent true and false.
The predefined literals true and false represent those values as the given example statement.

bool great_india = true;



▨ The literals true and false can be converted into int type.
Then true is 1 and false is 0:

Example statements:
int sun = true; // int sun assigned 1

int earth = false; // int earth assigned 0



▨ Any numeric value can be converted to a bool value.
As nonzero value converts to true, whereas a zero value converts to false.

Example statements:

bool pin = -100; // pin assigned as true

bool unpin = 0; // unpin assigned as false.



Related articles:
How to display a value in Hexadecimal form in C++?
How C++ identify the base of a number?
Symbolic Constant in C++




Popular Google Pages:



Top of the page

Amazon & Flipkart Special Products

   


Top of the page