Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Boolean | Other Data Types and Concepts
course content

Contenido del Curso

C++ Data Types

BooleanBoolean

Boolean (bool) is a data type that can take one of two values: true or false. Syntax:

They are mostly used in comparison operators. Those operators (==, !=, <, >, >=, <=) return bool.

Note

std::cout prints booleans as numbers, 1 if the boolean is true, and 0 if the boolean is false.

cpp

main.cpp

You can also flip the value of a boolean using the ! operator:

cpp

main.cpp

And most frequently, they are used as conditions in if/while/... statements.

cpp

main.cpp

The size of a bool in C++ is 1 byte. Yes, it would fit in 1 bit of memory, but you can't store a variable of size less than 1 byte (8 bit) in C++

Choose the INCORRECT statement

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 4. Capítulo 1
course content

Contenido del Curso

C++ Data Types

BooleanBoolean

Boolean (bool) is a data type that can take one of two values: true or false. Syntax:

They are mostly used in comparison operators. Those operators (==, !=, <, >, >=, <=) return bool.

Note

std::cout prints booleans as numbers, 1 if the boolean is true, and 0 if the boolean is false.

cpp

main.cpp

You can also flip the value of a boolean using the ! operator:

cpp

main.cpp

And most frequently, they are used as conditions in if/while/... statements.

cpp

main.cpp

The size of a bool in C++ is 1 byte. Yes, it would fit in 1 bit of memory, but you can't store a variable of size less than 1 byte (8 bit) in C++

Choose the INCORRECT statement

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 4. Capítulo 1
some-alt